I would like to know how to call a UDF function from a domain specific language (DSL) function in Spark SQL using JAVA.
I have a UDF function (e.g.):
UDF2 equals = new UDF2<String, String, Boolean>() { @Override public Boolean call(String first, String second) throws Exception { return first.equals(second); } };
I registered it in sqlContext
sqlContext.udf().register("equals", equals, DataTypes.BooleanType);
When I run the following query, my UDF is called and I get the result.
sqlContext.sql("SELECT p0.value FROM values p0 WHERE equals(p0.value, 'someString')");
I would forward this query using the functions of a domain-specific language in Spark SQL, and I'm not sure how to do this.
valuesDF.select("value").where(???);
I found that there is a callUDF () function, where one of its parameters is Function2 fnctn, but not UDF2. How can I use UDF and functions from DSL?
HR.AD source share