title: Spark SQL: How to call UDF from DataFrame operation using JAVA
body: <p>I would like to know how to call UDF function from function of domain-specific language(DSL) in Spark SQL using JAVA.</p>
  
  <p>I have UDF function (just for example):</p>
  
  <pre><code>UDF2 equals = new UDF2&lt;String, String, Boolean&gt;() {
     @Override
     public Boolean call(String first, String second) throws Exception {
         return first.equals(second);
     }
  };
  </code></pre>
  
  <p>I've registered it to sqlContext</p>
  
  <pre><code>sqlContext.udf().register("equals", equals, DataTypes.BooleanType);
  </code></pre>
  
  <p>When I run following query, my UDF is called and I get a result.</p>
  
  <pre><code>sqlContext.sql("SELECT p0.value FROM values p0 WHERE equals(p0.value, 'someString')");
  </code></pre>
  
  <p>I would transfrom this query using functions of domain specific language in Spark SQL, and I am not sure how to do it.</p>
  
  <pre><code>valuesDF.select("value").where(???);
  </code></pre>
  
  <p>I found that there exists callUDF() function where one of its parameters is Function2 fnctn but not UDF2. 
  How can I use UDF and functions from DSL?</p>