This repository includes a sample UDF function which checks the percentage of match between two strings.
export TUTORIAL_HOME=<Tutorial directory>/UDF-Flink-JWrinker
- To generate the necessary JAR File for upload via the CLI, execute the command below.
mvn clean package
NOTE : You can write your custom logic on public double eval() function based on your usecase by removing the existing code
To register the JAR file generated after executing the mvn clean package
command on the CC organization, start by logging into the Confluent CLI and then use the following command.
confluent flink artifact create
your-artifact-name
--artifact-file path-to-jar-file.JAR
Upon successful execution of the command, it will produce a plugin ID and version ID, which should resemble the following format.
+----------------+----------------+
| Name | artifact-name |
| Plugin ID | ccp-xxxxxxxxxxx |
| Version ID | ver-xxxxxxxxxxx |
| Content Format | JAR |
+----------------+----------------+
Utilize the command below to display a list of all uploaded artifacts.
confluent flink artifact list
Once you've uploaded the JAR using the CLI, proceed to the Flink SQL editor to register the UDF within your specific Flink workspace with the following command.
CREATE FUNCTION UDF_NAME
AS 'io.confluent.flink.table.modules.remoteudf.TShirtSizingIsSmaller'
USING JAR 'confluent-artifact://pluginid/versionid';
NOTE: Replace the class with your actual class that contains the eval function.
Now that the UDF is successfully registered, you can utilize the command below to display a list of all UDF functions:
SHOW USER FUNCTIONS;
Here is the Sample command which uses UDF function that we have just created
select regionid, FUNCTION UDF_NAME(gender,"MAALE") from sample data