title: How to convert org.apache.spark.sql.ColumnName to string,Decimal type in Spark Scala?
body: <p>I have a JSON  like below </p>
  
  <pre><code>{"name":"method1","parameter1":"P1name","parameter2": 1.0}
  </code></pre>
  
  <p>I am loading my JSON file </p>
  
  <pre><code>val sqlContext = new org.apache.spark.sql.SQLContext(sc)
  val df = sqlContext.read.json("C:/Users/test/Desktop/te.txt") 
  scala&gt; df.show()
  </code></pre>
  
  <pre class="lang-none prettyprint-override"><code>+-------+----------+----------+
  |   name|parameter1|parameter2|
  +-------+----------+----------+
  |method1|    P1name|    1.0   |
  +-------+----------+----------+
  </code></pre>
  
  <p>I have a function like below:</p>
  
  <pre><code>def method1(P1:String, P2:Double)={
       |  print(P1)
           print(P2)
       | }
  </code></pre>
  
  <p>I am calling my method1 based on column name after executing below code it should execute method1.</p>
  
  <pre><code>import org.apache.spark.sql.Column
  import org.apache.spark.sql.functions._
  df.withColumn("methodCalling", when($"name" === "method1", method1($"parameter1",$"parameter2")).otherwise(when($"name" === "method2", method2($"parameter1",$"parameter2")))).show(false)
  </code></pre>
  
  <p>But I am getting bellow error.</p>
  
  <pre class="lang-none prettyprint-override"><code>&lt;console&gt;:63: error: type mismatch;
   found   : org.apache.spark.sql.ColumnName
   required: String
  </code></pre>
  
  <p>Please let me know how to convert org.apache.spark.sql.ColumnName data type to String</p>