title: How to add prefix and suffix values for a column in spark dataframe using scala
body: <p>Input dataframe </p>
  
  <pre><code>    val ds = Seq((1,"play Framwork"),
    (2,"Spark framework"),
    (3,"spring framework")).toDF("id","subject")
  </code></pre>
  
  <p>Suppose my <code>prefix</code> value is <strong>prefix</strong> and <code>suffix</code> is <strong>suffix</strong> . Then i expect the following <strong>DataFrame</strong></p>
  
  <p>Expected dataframe</p>
  
  <pre><code> val ds = Seq((1,"play Framwork",prefixplay Frameworksuffix),
    (2,"Spark framework",prefixSpark frameworksuffix),
    (3,"spring framework"),prefixspring frameworksuffix).toDF("id","subject",prefixsubjectsuffix)
  </code></pre>
  
  <p>So as you can see , i am expecting a new colunm to be created with name as <code>prefix+columnName+suffix</code> as <strong>prefixsubjectsuffix</strong> . Also the <code>values</code> of that column should be converted as my expected .</p>
  
  <p>I am trying to use some <code>udf</code> to achieve this like as below </p>
  
  <pre><code>    import org.apache.spark.sql.functions.udf
    val concatPrefixSuffixWithColumnValues=
  udf((column:String,prefix:String,suffix:String)=&gt;
  prefix.concat(column).concat(suffix))
  </code></pre>
  
  <p>But when i use it through the following statement gives some compilation error </p>
  
  <pre><code>dataset.withColumn(s"$prefixsubject$suffix",concatPrefixSuffixWithColumnValues("subject",prefix,suffix))
  </code></pre>
  
  <p>So how can i achieve this . Any references ??</p>