CREATE FUNCTION Statement
Confluent Cloud for Apache Flink® enables registering custom user-defined functions (UDFs) by using the CREATE FUNCTION statement. After you register your UDFs in a Flink database, you can use them in your SQL queries.
Syntax
CREATE FUNCTION <function_name>
AS <class_name>
USING JAR 'confluent-artifact://<artifact_id>'
[USING CONNECTIONS ('<connection_name>' [, ...])];
Description
Register a user-defined function (UDF) in the current database.
The optional USING CONNECTIONS clause binds one or more
connection objects to the UDF, enabling
external connectivity so the
function can call external systems at runtime. Provide one or more
connection names, separated by commas. The connection name must match the
prefix that the UDF uses with FunctionContext.getJobParameter(). For
example, use USING CONNECTIONS ('my_external_service') for a
my_external_service.endpoint parameter.
To remove a UDF from the current database, use DROP FUNCTION.
To view the UDFs in the current database, use SHOW FUNCTIONS.
Note
UDFs are immutable. Flink has no ALTER FUNCTION or CREATE OR REPLACE
FUNCTION statement, so to update a UDF, drop it and create a new
function that points to the updated artifact. Dropping a function that other
statements depend on can break the other statements. To ensure your
statements work, see Update a UDF safely.