title: convert each row of dataframe to a map
body: <p>I have a dataframe with columns A &amp; B of type String. Let's assume the below dataframe</p>
  
  <pre><code>+--------+
  |A  | B  |
  |1a | 1b |
  |2a | 2b |
  </code></pre>
  
  <p>I want to add a third column that creates a map of A &amp; B column</p>
  
  <pre><code>+-------------------------+
  |A  | B  |  C             |
  |1a | 1b | {A-&gt;1a, B-&gt;1b} |
  |2a | 2b | {A-&gt;2a, B-&gt;2b} |
  </code></pre>
  
  <p>I'm attempting to do it the following way. I have udf which takes in a dataframe and returns a map</p>
  
  <pre><code>val test = udf((dataFrame: DataFrame) =&gt; {
  val result = new mutable.HashMap[String, String]
  dataFrame.columns.foreach(col =&gt; {
    result.put(col, dataFrame(col).asInstanceOf[String])
  })
  result
  })
  </code></pre>
  
  <p>I'm calling this udf in following way which is throwing a RunTimeException as I'm trying to pass a DataSet as a literal</p>
  
  <pre><code>df.withColumn("C", Helper.test(lit(df.select(df.columns.head, df.columns.tail: _*)))
  </code></pre>
  
  <p>I don't want to pass df('a') df('b') to my helper udf as I want them to be generic list of columns that I could select. 
  any pointers?</p>