You can create User Defined Functions (UDF) using Java after manually adding the UDF
function JAR file that contains the UDF class to the Flink connectors. After uploading the
JAR file on the Streaming SQL Console, you can use the Java UDFs for your SQL
jobs.
-
Create a Java UDF function JAR file.
You can use the following example as a
sample:
package udf;
import org.apache.flink.table.functions.ScalarFunction;
public class UdfTest extends ScalarFunction {
public String eval(String input){
return "Hello World " + input;
}
}
-
Navigate to the Streaming SQL Console.
-
Go to your cluster in Cloudera Manager.
-
Select SQL Stream Builder from the list of services.
-
Click .
The Streaming SQL Console opens in a new window.
-
Select Functions from the main menu.
-
Click Upload JAR.
-
Click Choose File.
-
Search and select the Java UDF function JAR file.
-
Click Create.
The selected JAR file is uploaded, and listed on the Functions
page and ready to be used in your SQL queries.