DESCRIBE FUNCTION
Returns the metadata about an existing user-defined function.
Syntax{ DESC | DESCRIBE } FUNCTION <function_name>
Parameters
<function_name> String
The name of an existing user-defined function. This commands returns the following:
Name
- The name of the function.Input
- The parameters of the function with one tuple per line:parameter_name data_type
Returns
- The return type of the function. For a scalar function, show data_type. For a tabular function, showTABLE ( column_spec [, ...] )
Owner
- The current owner of the function.Created At
- The timestamp of when the function was created.Modified At
- The timestamp of when the function was last modified.Body
- The body of the function, namely,expression
orquery
from theCREATE FUNCTION … RETURN
clause.
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 $scratch.t WHERE $scratch.t.name = find_fruit.name
AND $scratch.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 "$scratch"."t10"\nWHERE ("$scratch"."t"."color" = "color")