Concatenate String to each element of a List in a Spark dataframe with Scala
<p>I have two columns in a Spark dataframe: one is a String, and the other is a List of Strings. How do I create a new column that is the concatenation of the String in column one with each element of the list in column 2, resulting in another list in column 3. </p>

<p>For example, if column 1 is "a", and column 2 is ["A","B"], I'd like the output in column 3 of the dataframe to to be ["aA","aB"].</p>

<p>So far, I have:</p>

<pre><code>val multiplier = (x1: String, x2: Seq[String]) =&gt; {x1+x2}
val multiplierUDF = udf(multiplier)
val df2 = df1
  .withColumn("col3", multiplierUDF(df1("col1"),df1("col2")))
</code></pre>

<p>which gives <code>aWrappedArray(A,B)</code></p>