CREATE FUNCTION
Only valid for approved Organizations. Please reach out to us to enable Functions.
Syntax
Description
Defines a new User-Defined Function (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 has to be unique within an organization. The signature is a combination of the name, parameter types, and return type of the Function.
See the Creating a Function tutorial for a full example of adding a Function.
Arguments
function_name
Name of the Function to create. For case-sensitive names, the name must be wrapped in double quotes, otherwise, the lowercased name will be used.
(arg_name arg_type [,…])
An ordered list of Function argument names and types.
return_type
Data type for a Function’s result value.
language_name
Language in which the Function was created. Supports JAVA
.
WITH (function_parameter = value [, … ])
This clause specifies the Function Parameters.
Function Parameters
Parameter Name | Description |
---|---|
| Required. Specifies an existing Function Source to use for the content of the Function. See LIST FUNCTION_SOURCES. Type: String Valid values: A function_source that the user has access to. See LIST FUNCTION_SOURCES. |
| Required. Specifies the fully qualified class name defined within a Function Source. Type: String Valid values: A valid class name in the function_source. |
| Optional. Specifies a comma delimited list of |
Example
Create user-defined Function with single input argument
The below DDL statement creates a new user-defined Function with the name toUpperCase
. The Function accepts one argument of the data type VARCHAR
and 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 CREATE FUNCTION SOURCE for details on how a Function Source can be added.
You can use LIST FUNCTIONS command to get a list of created functions.
Create user-defined Function with multiple input arguments
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
.
Create user-defined Function with egress.allow.uris property
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 will be blocked.
Last updated