Hi Greg,
We tried everything you have mentioned with no luck.
1. We have added the jar file to spark
2. We have added it to spark-defaults.conf as follows
spark.executor.extraClassPath /var/tmp/LowerCase.jar
spark.executor.extraLibraryPath /var/tmp/LowerCase.jar
3. We have registered the UDF in kylo spark shell. Registration is done by creating a wrapper function that registers and returns the value of the functions.callUDF()
Registration done using spark submit:
spark-submit --class com.tekclan.spark.udf.LowerCase /var/tmp/LowerCase.jar
Jar file is generated from the below mentioned code:
package com.tekclan.Spark.udf;
import org.apache.spark.api.java.*;
import org.apache.spark.SparkConf;
import org.apache.spark.sql.*;
import org.apache.spark.sql.api.java.UDF1;
import org.apache.spark.sql.types.DataTypes;
public class LowerCase {
public static void main(String[] args) {
SparkConf conf = new SparkConf().setAppName("Java UDF Example");
JavaSparkContext sc = new JavaSparkContext(conf);
SQLContext sqlContext = new org.apache.spark.sql.SQLContext(sc);
System.out.println("Before ");
// Register the UDF with our SQLContext
sqlContext.udf().register("LCUDF", new UDF1<String, String>() {
public String call(String t1) {
System.out.println("SPARK UDF CREATED SUCCESSFULLY : " + t1.toLowerCase());
return t1.toLowerCase();
}
}, DataTypes.StringType);
System.out.println("After ");
}
}
4. We have used this function in the spark-functions.json file
{
"!name": "my-spark-functions",
"lowercase": {
"!type": "fn(udfName: String, col1: column) -> column",
"!doc": "Converts to lower case",
5. This function is called in the kylo UI as follows
lowercase("LCUDF",pxcreateopname)
But still we get to see the same old issue. Analysis Exception undefined function LCUDF
What could be the reason for this? we are unable to get it to work.