title: Spark UDF type mismatch error
body: <p>I'm trying to write a UDF to convert a timestamp into an integer representing the hour of the week.  I'm easily able to accomplish this with SparkSql like this.</p>
  
  <p><a href="https://i.stack.imgur.com/34wIn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/34wIn.png" alt="enter image description here"></a></p>
  
  <p>I have many UDFs in our code with this exact syntax but this one is trying a type mismatch error.  I also tried invoking my UDF with <code>col("session_ts_start")</code> but that also failed to work.  </p>
  
  <pre class="lang-scala prettyprint-override"><code>import spark.implicits._
  import java.sql.Timestamp
  import org.apache.spark.sql.functions._
  
  def getHourOfWeek() = udf(
      (ts: Timestamp) =&gt; unix_timestamp(ts)
  )
  
  val dDF = df.withColumn("hour", getHourOfWeek()(df("session_ts_start")))
  dDF.show()
  
  &lt;console&gt;:154: error: type mismatch;
   found   : java.sql.Timestamp
   required: org.apache.spark.sql.Column
             (ts: Timestamp) =&gt; unix_timestamp(ts)
  </code></pre>