title: How to rename column names in spark SQL
body: <p>I have a dataframe with configurable column names eg</p>
  
  <pre><code>Journey channelA channelB channelC
  j1      1        0        0
  j1      0        1        0
  j1      1        0        0
  j2      0        0        1 
  j2      0        1        0
  </code></pre>
  
  <p>By configurable I mean there could be 'n' channels in the dataframe.</p>
  
  <p>Now I need to a transformation in which I need to find the sum of all channels something like </p>
  
  <pre><code>df.groupBy("Journey").agg(sum("channelA"), sum("channelB"), sum("channelC"))
  </code></pre>
  
  <p>The output of which would be :</p>
  
  <pre><code>Journey sum(channelA) sum(channelB) sum(channelC)
  j1      2             1             0
  j2      0             1             1
  </code></pre>
  
  <p>Now i want to rename the column names to the original names and I could do it with</p>
  
  <pre><code>.withColumnRenamed("sum(channelA)", channelA)
  </code></pre>
  
  <p>but as i mentioned the channel list is configurable and I would want a generic column rename statement to rename all my summed columns to the original column names to get an expected dataframe as :</p>
  
  <pre><code>Journey channelA channelB channelC
  j1      2        1             0
  j2      0        1             1
  </code></pre>
  
  <p>Any suggestions how to approach this</p>