CREATE FUNCTION
Last updated
Last updated
Defines a new (UDF), an executable routine defined in a supported language, which accepts an ordered list of input arguments, performs a computation, and generates a result value.
The name and parameter types of a function’s signature must be unique within an organization. The signature is a combination of the name, parameter types, and return type of the function.
See the tutorial for a full example of adding a .
Name of the function to create. If the name is case sensitive you must wrap it in double quotes; otherwise the system uses the lower case name.
An ordered list of function argument names and types.
Data type for a function’s result value.
Language in which the function was created. Supports JAVA
.
source.name
class.name
Required. Specifies the fully-qualified class name defined within a function source. Type: String Valid values: A valid class name in the function_source.
egress.allow.uris
Optional. Specifies a comma delimited list of host:port
endpoints that the function
can send requests. This is only needed if a function needs to call a remote service.
You can use LIST FUNCTIONS command to get a list of created functions.
The below DDL statement creates a new user-defined function called getrate
from a Java class with the name accounting.Exchange
available in the finance
function source. This function receives two input arguments of data types VARCHAR
and BIGINT
, and generates an output of the data type DECIMAL
.
The below DDL statement creates a new user-defined function called getrate
from a Java class with the name accounting.Exchange
available in the finance
function source. This function receives two input arguments of data types VARCHAR
and BIGINT
, and generates an output of the data type DECIMAL
.
This function will can also make remote calls to myhost1:9090
and myhost2:80
. Without the egress.allow.uris
property, the function calls are blocked.
This clause specifies the .
Required. Specifies an existing function Source to use for the content of the function. See . Type: String Valid values: A function_source to which the user has access. See .
The below DDL statement creates a new user-defined function with the name toUpperCase
. The function accepts one argument of the data type VARCHAR;
the data type of its return value is also VARCHAR
. The function's executable code is in a Java class with the name util.UpperCase
available in the mysrc
function source. Check for details on how to add a function source.