title: Prefix all spark dataframe columns except primary key column
body: <p>Below is the code i have for prefixing column names. I want to exclude one or multiple primary key columns. My primaryKeys is a string array which may contain 1 or more primary key fields.</p>
  
  <pre><code>val primaryKeys = args(2).split("-")
  
  val prefix = "w1."
  val renamedColumns = df.columns.map(c=&gt; df(c).as(s"$prefix$c"))
  val dfNew = df.select(renamedColumns: _*)
  
  val prefix2 = "w2."
  val renamedColumns2 = df2.columns.map(c2=&gt; df2(c2).as(s"$prefix2$c2"))
  val df2New = df2.select(renamedColumns2: _*)
  
  If it is just one column i was able to rename using withColumnRenamed but i am unable to do it if i have multiple primary columns. 
  </code></pre>
  
  <p>I am unable to do something like this</p>
  
  <pre><code>for (primaryKey &lt;- primaryKeys) {
   dfNew.withColumnRenamed("$PREFIX1"+s"${primaryKey}",s"$primaryKey").toDF()
  }
  </code></pre>
  
  <p>Can someone help?</p>