snowflake.core.user_defined_function.UserDefinedFunctionResource¶
- class snowflake.core.user_defined_function.UserDefinedFunctionResource(name_with_args: str, collection_class: UserDefinedFunctionCollection)¶
Bases:
UserDefinedFunctionResourceBaseRepresents a reference to a Snowflake user defined function.
With this user defined function reference, you can fetch information about a user defined function, as well as perform certain actions on it.
Attributes
- database¶
The DatabaseResource this reference belongs to.
- fully_qualified_name¶
Return the fully qualified name of the object this reference points to.
- root¶
The Root object this reference belongs to.
Methods
- drop(if_exists: bool | None = None) None¶
Delete a UDF.
- Parameters:
if_exists (bool) – 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.
- drop_async(if_exists: bool | None = None) PollingOperation[None]¶
An asynchronous version of
drop().Refer to
PollingOperationfor more information on asynchronous execution and the return type.
- execute(input_args: list[UserDefinedFunctionArgument] | None = None) Any¶
Execute this user defined function.
- Parameters:
input_args (list[UserDefinedFunctionArgument], optional) – A list of arguments to pass to the function. The number of arguments must match the number of arguments the user defined function expects. Name, datatype and value fields of UserDefinedFunctionArgument are required.
Examples
Executing a user defined function using its reference:
>>> user_defined_function_reference.execute( ... [ ... UserDefinedFunctionArgument(name="id", datatype="INT", value=42), ... UserDefinedFunctionArgument(name="tableName", datatype="TEXT", value="my_table_name"), ... ] ... )
- execute_async(input_args: list[UserDefinedFunctionArgument] | None = None) PollingOperation[Any]¶
An asynchronous version of
execute().Refer to
PollingOperationfor more information on asynchronous execution and the return type.
- fetch() UserDefinedFunction¶
Fetch a UDF.
- fetch_async() PollingOperation[UserDefinedFunction]¶
An asynchronous version of
fetch().Refer to
PollingOperationfor more information on asynchronous execution and the return type.
- rename(target_name: str, target_database: str | None = None, target_schema: str | None = None, if_exists: bool | None = None) None¶
Rename this user defined function.
- Parameters:
target_name (str) – The new name of the user defined function
target_database (str, optional) – The database where the user defined function will be located
target_schema (str, optional) – The schema where the user defined function will be located
if_exists (bool, optional) – Check the existence of user defined function before rename
Examples
Renaming this user defined function using its reference:
>>> user_defined_function_reference.rename("my_other_user_defined_function")
Renaming this user defined function if it exists:
>>> user_defined_function_reference.rename("my_other_user_defined_function", if_exists=True)
Renaming this user defined function and relocating it to another schema within same database:
>>> user_defined_function_reference.rename( ... "my_other_user_defined_function", target_schema="my_other_schema", if_exists=True ... )
Renaming this user defined function and relocating it to another database and schema:
>>> user_defined_function_reference.rename( ... "my_other_user_defined_function", ... target_database="my_other_database", ... target_schema="my_other_schema", ... if_exists=True, ... )
- rename_async(target_name: str, target_database: str | None = None, target_schema: str | None = None, if_exists: bool | None = None) PollingOperation[None]¶
An asynchronous version of
rename().Refer to
PollingOperationfor more information on asynchronous execution and the return type.