title: Create new column with function in Spark Dataframe
body: <p>I'm trying to figure out the new dataframe API in Spark. Seems like a good step forward but having trouble doing something that should be pretty simple.  I have a dataframe with 2 columns, &quot;ID&quot; and &quot;Amount&quot;.  As a generic example, say I want to return a new column called &quot;code&quot; that returns a code based on the value of &quot;Amt&quot;.  I can write a function something like this:</p>
  <pre><code>def coder(myAmt:Integer):String {
    if (myAmt &gt; 100) &quot;Little&quot;
    else &quot;Big&quot;
  }
  </code></pre>
  <p>When I try to use it like this:</p>
  <pre><code>val myDF = sqlContext.parquetFile(&quot;hdfs:/to/my/file.parquet&quot;)
  
  myDF.withColumn(&quot;Code&quot;, coder(myDF(&quot;Amt&quot;)))
  </code></pre>
  <p>I get type mismatch errors</p>
  <pre><code>found   : org.apache.spark.sql.Column
  required: Integer
  </code></pre>
  <p>I've tried changing the input type on my function to org.apache.spark.sql.Column but I then I start getting errors with the function compiling because it wants a boolean in the if statement.</p>
  <p>Am I doing this wrong?  Is there a better/another way to do this than using withColumn?</p>
  <p>Thanks for your help.</p>