functions
Creates, updates, deletes, gets or lists a functions
resource.
Overview
Name | functions |
Type | Resource |
Id | snowflake.function.functions |
Fields
Name | Datatype | Description |
---|---|---|
name | string | Specifies the name for the function, must be unique for the schema in which the function is created |
arguments | array | |
body | string | Function's body. |
created_on | string | Date and time when the function was created. |
function_type | string | |
language | string | Function's language. |
max_batch_rows | integer | Specifies the max rows for batch operation. |
returns | string | Specifies the type for the function return value. |
signature | string | Function's arguments. |
Methods
Name | Accessible by | Required Params | Optional Params | Description |
---|---|---|---|---|
fetch_function | SELECT | database_name, nameWithArgs, schema_name, endpoint | - | Fetch a Function using the describe command output. |
list_functions | SELECT | database_name, schema_name, endpoint | like | Lists the user functions under the database and schema. |
create_function | INSERT | database_name, schema_name, data__arguments, data__name, endpoint | createMode | Create a function. |
delete_function | DELETE | database_name, nameWithArgs, schema_name, endpoint | ifExists | Delete a function with the given name and args. |
execute_function | EXEC | database_name, name, schema_name, endpoint | - | Execute a Function. |
Optional Parameter Details
Name | Description | Type | Default |
---|---|---|---|
createMode | Query parameter allowing support for different modes of resource creation. Possible values include: - errorIfExists : Throws an error if you try to create a resource that already exists. - orReplace : Automatically replaces the existing resource with the current one. - ifNotExists : Creates a new resource when an alter is requested for a non-existent resource. | string | errorIfExists |
ifExists | Query parameter that specifies how to handle the request for a resource that does not exist: - true : The endpoint does not throw an error if the resource does not exist. It returns a 200 success response, but does not take any action on the resource. - false : The endpoint throws an error if the resource doesn't exist. | boolean | false |
like | Query parameter to filter the command output by resource name. Uses case-insensitive pattern matching, with support for SQL wildcard characters. | string | - |
SELECT
examples
- list_functions
- fetch_function
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 }}';
Fetch a Function using the describe command output.
SELECT
name,
arguments,
body,
created_on,
function_type,
language,
max_batch_rows,
returns,
signature
FROM snowflake.function.functions
WHERE database_name = '{{ database_name }}'
AND nameWithArgs = '{{ nameWithArgs }}'
AND schema_name = '{{ schema_name }}'
AND endpoint = '{{ endpoint }}';
INSERT
example
Create a function.
- Required Properties
- All Properties
- Manifest
/*+ 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 }}'
;
/*+ create */
INSERT INTO snowflake.function.functions (
data__name,
data__arguments,
database_name,
schema_name,
endpoint
)
SELECT
'{{ name }}',
'{{ arguments }}',
'{{ database_name }}',
'{{ schema_name }}',
'{{ endpoint }}'
;
# Description fields below are for documentation purposes only and are not required in the manifest
- name: functions
props:
- name: database_name
value: string
description: Required parameter for the functions resource.
- name: schema_name
value: string
description: Required parameter for the functions resource.
- name: endpoint
value: string
description: Required parameter for the functions resource.
- name: function_type
value: string
default: service-function
- name: name
value: string
description: >-
Specifies the name for the function, must be unique for the schema in
which the function is created (Required parameter for the functions
resource.)
- name: arguments
value:
- name: name
value: string
description: Argument's name
- name: datatype
value: string
description: >-
Argument's type (valid values: 'FIXED', 'INT', 'REAL', 'NUMBER',
'TEXT', 'BOOLEAN', 'DATE', 'TIME', 'TIMESTAMP_TZ', 'TIMESTAMP_LTZ',
'TIMESTAMP_NTZ')
default: TEXT
- name: value
value: string
description: Argument's value
description: Required parameter for the functions resource.
- name: returns
value: string
description: >-
Specifies the type for the function return value. (valid values:
'FIXED', 'INT', 'REAL', 'NUMBER', 'TEXT', 'BOOLEAN', 'DATE', 'TIME',
'TIMESTAMP_TZ', 'TIMESTAMP_LTZ', 'TIMESTAMP_NTZ')
default: TEXT
- name: max_batch_rows
value: integer
description: Specifies the max rows for batch operation.
- name: created_on
value: string
description: Date and time when the function was created.
- name: signature
value: string
description: Function's arguments.
- name: language
value: string
description: Function's language.
- name: body
value: string
description: Function's body.
DELETE
example
Delete a function with the given name and args.
/*+ delete */
DELETE FROM snowflake.function.functions
WHERE database_name = '{{ database_name }}'
AND nameWithArgs = '{{ nameWithArgs }}'
AND schema_name = '{{ schema_name }}'
AND endpoint = '{{ endpoint }}';