snowflake.core.user_defined_function.UserDefinedFunctionResource¶
- class snowflake.core.user_defined_function.UserDefinedFunctionResource(name_with_args: str, collection: UserDefinedFunctionCollection)¶
Bases:
SchemaObjectReferenceMixin
[UserDefinedFunctionCollection
]Represents a reference to a Snowflake user defined function.
With this user defined function reference, you can create, drop, rename and fetch information about user defined functions.
Attributes
- database¶
- fully_qualified_name¶
- root¶
Methods
- drop(if_exists: bool | None = None) None ¶
Drop this user defined function.
- Parameters:
if_exists (bool, optional) – Check the existence of this user defined function before dropping it. Default is
None
, which is equivalent toFalse
.
Examples
Deleting this user defined function using its reference:
>>> user_defined_function_reference.drop()
Deleting this user defined function if it exists:
>>> user_defined_function_reference.drop(if_exists = True)
- fetch() UserDefinedFunction ¶
Fetch the details of a user defined function.
Examples
Fetching a user defined function reference to print its time of creation:
>>> print(user_defined_function_reference.fetch().created_on)
- 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 ... )