DESCRIBE FUNCTION Enterprise
Returns the metadata about an existing user-defined function (UDF) in the Arctic catalog.
Syntax{ DESC | DESCRIBE } FUNCTION <function_name>
[ AT { REF[ERENCE] | BRANCH | TAG | COMMIT } <reference_name> ]
[ AS OF <timestamp> ]
To run DESCRIBE FUNCTION, users need the USAGE privilege on the Arctic catalog and SELECT privilege on the UDF.
Parameters
<function_name> String
The name of an existing UDF.
AT { REF[ERENCE] | BRANCH | TAG | COMMIT } <reference_name> String Optional
Specifies the reference at which the UDF exists. When this parameter is omitted, the current reference is used.
REF
: Identifies a specific branch, tag, or commit.BRANCH
: Identifies a specific branch.TAG
: Identifies a specific tag.COMMIT
: Identifies a specific commit. Commit hashes must be enclosed in double quotes (for example,“ff2fe50fef5a030c4fc8e61b252bdc33c72e2b6f929d813833d998b8368302e2”
.
AS OF <timestamp> String Optional
Changes the commit reference point to the provided timestamp. Can only be applied to REF
, BRANCH
, and TAG
. <timestamp>
may be any SQL expression that resolves to a single timestamp type value, for example: CAST( DATE_SUB(CURRENT_DATE,1) AS TIMESTAMP )
or TIMESTAMP '2022-07-01 01:30:00.000'
.
Examples
Display the metadata for a scalar functionCREATE FUNCTION hello() RETURNS VARCHAR RETURN 'Hello World!';
DESCRIBE FUNCTION hello
-- Name: hello
-- Input: ()
-- Returns: VARCHAR
-- Owner: gnarly@example.com
-- Created At: Wed May 11 17:20:35 EDT 2022
-- Modified At: Wed May 11 17:20:35 EDT 2022
-- Body: 'Hello World!'
CREATE FUNCTION area (x DOUBLE, y DOUBLE) RETURNS DOUBLE RETURN x * y;
DESCRIBE FUNCTION area
-- Name: area
-- Type: SCALAR
-- Input: x DOUBLE
y DOUBLE
-- Returns: DOUBLE
-- Owner: gnarly@example.com
-- Created At: Mon Apr 25 19:31:28 EDT 2022
-- Modified At: Mon May 09 09:01:57 EDT 2022
-- Body: x * y
CREATE FUNCTION find_fruit (name VARCHAR, color VARCHAR)
RETURNS TABLE (name VARCHAR, color VARCHAR)
RETURN SELECT * FROM <catalog-name>.t WHERE <catalog-name>.t.name = find_fruit.name
AND <catalog-name>.t.color = find_fruit.color;
DESCRIBE FUNCTION find_fruit
-- Name: find_fruit
-- Input: "name": "color", "type": "varchar"
-- Returns: struct<name::varchar>
-- Owner: gnarly@example.com
-- Created At: Mon Apr 25 19:31:28 EDT 2022
-- Modified At: Mon May 09 09:01:57 EDT 2022
-- Body: SELECT "name"\nFROM "<catalog-name>"."t10"\nWHERE ("<catalog-name>"."t"."color" = "color")
Columns
Column | Data Type | Description |
---|---|---|
Name | varchar | The name of the function. |
Input | varchar | The parameters of the function with one tuple per line: parameter_name data_type . |
Returns | varchar | The return type of the function. For a scalar function, show <data_type>. For a tabular function, show TABLE ( <column_name> [, ...] ) . |
Body | varchar | The body of the function, namely, expression or query from the CREATE FUNCTION … RETURN clause. |
Created_At | timestamp | The timestamp of when the function was created. |
Last_Modified_At | timestamp | The timestamp of when the function was last modified. |
Owner | varchar | The current owner of the function. |