CREATE FUNCTION
CREATE FUNCTION
Description
Creates a user-defined function (UDF). Currently, you can only create Java UDFs, including Scalar functions, user-defined aggregate functions (UDAFs), user-defined window functions (UDWFs), and user-defined table functions (UDTFs).
For details about how to compile, create, and use a Java UDF, see Java UDF.
NOTE
To create a global UDF, you must have the SYSTEM-level CREATE GLOBAL FUNCTION privilege. To create a database-wide UDF, you must have the DATABASE-level CREATE FUNCTION privilege.
Syntax
CREATE [GLOBAL][AGGREGATE | TABLE] FUNCTION function_name
(arg_type [, ...])
RETURNS return_type
PROPERTIES ("key" = "value" [, ...])
Parameters
Parameter | Required | Description |
---|---|---|
GLOBAL | No | Whether to create a global UDF, supported from v3.0. |
AGGREGATE | No | Whether to create a UDAF or UDWF. |
TABLE | No | Whether to create a UDTF. If both |
function_name | Yes | The name of the function you want to create. You can include the name of the database in this parameter, for example, |
arg_type | Yes | Argument type of the function. The added argument can be represented by |
return_type | Yes | The return type of the function. For the supported data types, see Java UDF . |
PROPERTIES | Yes | Properties of the function, which vary depending on the type of the UDF to create. For details, see Java UDF 。 |