title: Error calculating squared distance in Spark / Scala
body: <p>I need to calculate squared distance between two features columns of a
  Spark dataframe. When I run the following code  </p>
  
  <pre class="lang-scala prettyprint-override"><code>val udf_dist = funcs.udf((x:DenseVector, y:DenseVector) =&gt; Vectors.sqdist(x,y))
  val df6 = df5.withColumn("dist", udf_dist(funcs.col("features"),
                           funcs.col("features2")))
  </code></pre>
  
  <p>I get error</p>
  
  <blockquote>
    <p>Name: org.apache.spark.sql.AnalysisException<br>
    Message: cannot resolve
    'UDF(features, features2)' due to data type mismatch: argument 1
    requires vector type, however, '<code>features</code>' is of vector type.
    argument 2 requires vector type, however, '<code>features2</code>' is of vector
    type.</p>
  </blockquote>
  
  <p>The schema of my dataframe is</p>
  
  <pre><code>root
   |-- id: long (nullable = false)
   |-- features: vector (nullable = true)
   |-- id2: long (nullable = false)
   |-- features2: vector (nullable = true)
  </code></pre>
  
  <p>Also, the code below runs fine</p>
  
  <pre class="lang-scala prettyprint-override"><code>val v1: org.apache.spark.mllib.linalg.Vector = Vectors.dense(5)
  val v2: org.apache.spark.mllib.linalg.Vector = Vectors.dense(5)
  
  Vectors.sqdist(v1, v2)
  </code></pre>
  
  <p>Why I'm getting this error?</p>