Skip to main content

user_defined_functions

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

Overview

Nameuser_defined_functions
TypeResource
Idsnowflake.user_defined_function.user_defined_functions

Fields

NameDatatypeDescription
namestringThe name of the UDF
argumentsarrayList of arguments for the function/procedure
bodystringFunction/procedure definition
commentstringSpecifies a comment for the function/procedure
created_onstringThe date and time when the function/procedure was created
database_namestringThe name of the database in which the function/procedure exists.
is_aggregatebooleanSpecifies whether the UDF is an aggregate function. Applicable only for Python language type
is_builtinbooleanIf the function/procedure is built-in or not (user-defined)
is_memoizablebooleanIndicates whether the function is memoizable. Applicable only for Python language type.
is_securebooleanSpecifies whether the function/procedure is secure or not
is_table_functionbooleanTrue if the UDF is a table function; false otherwise.
is_temporarybooleanSpecifies whether the UDF is temporary or not
language_configobject
max_num_argumentsintegerThe maximum number of arguments
min_num_argumentsintegerThe minimum number of arguments
ownerstringRole that owns the function/procedure
owner_role_typestringThe type of role that owns the function/procedure
return_typeobject
schema_namestringThe name of the schema in which the function/procedure exists.
valid_for_clusteringbooleanTrue if the UDF is valid for clustering; false otherwise.

Methods

NameAccessible byRequired ParamsDescription
fetch_user_defined_functionSELECTdatabase_name, nameWithArgs, schema_name, endpointFetch a UDF
list_user_defined_functionsSELECTdatabase_name, schema_name, endpointList UDFs
create_user_defined_functionINSERTdatabase_name, schema_name, data__arguments, data__language_config, data__name, data__return_type, endpointCreate a UDF
delete_user_defined_functionDELETEdatabase_name, nameWithArgs, schema_name, endpointDelete a UDF
rename_user_defined_functionEXECdatabase_name, nameWithArgs, schema_name, targetDatabase, targetName, targetSchema, endpointRename a UDF

SELECT examples

List UDFs

SELECT
name,
arguments,
body,
comment,
created_on,
database_name,
is_aggregate,
is_builtin,
is_memoizable,
is_secure,
is_table_function,
is_temporary,
language_config,
max_num_arguments,
min_num_arguments,
owner,
owner_role_type,
return_type,
schema_name,
valid_for_clustering
FROM snowflake.user_defined_function.user_defined_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 user_defined_functions resource.

/*+ create */
INSERT INTO snowflake.user_defined_function.user_defined_functions (
data__name,
data__is_temporary,
data__is_aggregate,
data__is_memoizable,
data__is_secure,
data__arguments,
data__return_type,
data__language_config,
data__comment,
data__body,
database_name,
schema_name,
endpoint
)
SELECT
'{{ name }}',
'{{ is_temporary }}',
'{{ is_aggregate }}',
'{{ is_memoizable }}',
'{{ is_secure }}',
'{{ arguments }}',
'{{ return_type }}',
'{{ language_config }}',
'{{ comment }}',
'{{ body }}',
'{{ database_name }}',
'{{ schema_name }}',
'{{ endpoint }}'
;

DELETE example

Deletes the specified user_defined_functions resource.

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