Skip to main content

functions

Creates, updates, deletes, gets or lists a functions resource.

Overview

Namefunctions
TypeResource
Idsnowflake.function.functions

Fields

NameDatatypeDescription
namestringSpecifies the name for the function, must be unique for the schema in which the function is created
argumentsarray
bodystringFunction's body.
created_onstringDate and time when the function was created.
function_typestring
languagestringFunction's language.
max_batch_rowsintegerSpecifies the max rows for batch operation.
returnsstringSpecifies the type for the function return value.
signaturestringFunction's arguments.

Methods

NameAccessible byRequired ParamsDescription
fetch_functionSELECTdatabase_name, nameWithArgs, schema_name, endpointFetch a Function using the describe command output.
list_functionsSELECTdatabase_name, schema_name, endpointLists the user functions under the database and schema.
create_functionINSERTdatabase_name, schema_name, data__arguments, data__name, endpointCreate a function.
delete_functionDELETEdatabase_name, nameWithArgs, schema_name, endpointDelete a function with the given name and args.
execute_functionEXECdatabase_name, name, schema_name, endpointExecute a Function.

SELECT examples

Lists the user functions under the database and schema.

SELECT
name,
arguments,
body,
created_on,
function_type,
language,
max_batch_rows,
returns,
signature
FROM snowflake.function.functions
WHERE database_name = '{{ database_name }}'
AND schema_name = '{{ schema_name }}'
AND endpoint = '{{ endpoint }}';

INSERT example

Use the following StackQL query and manifest file to create a new functions resource.

/*+ create */
INSERT INTO snowflake.function.functions (
data__function_type,
data__name,
data__arguments,
data__returns,
data__max_batch_rows,
data__created_on,
data__signature,
data__language,
data__body,
database_name,
schema_name,
endpoint
)
SELECT
'{{ function_type }}',
'{{ name }}',
'{{ arguments }}',
'{{ returns }}',
'{{ max_batch_rows }}',
'{{ created_on }}',
'{{ signature }}',
'{{ language }}',
'{{ body }}',
'{{ database_name }}',
'{{ schema_name }}',
'{{ endpoint }}'
;

DELETE example

Deletes the specified functions resource.

/*+ delete */
DELETE FROM snowflake.function.functions
WHERE database_name = '{{ database_name }}'
AND nameWithArgs = '{{ nameWithArgs }}'
AND schema_name = '{{ schema_name }}'
AND endpoint = '{{ endpoint }}';