snowflake.core.user_defined_function.UserDefinedFunctionResource | Snowflake Documentation (original) (raw)

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

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

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 to False.

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)

drop_async(if_exists: bool | None = None) → PollingOperation[None]

An asynchronous version of drop().

Refer to PollingOperation for more information on asynchronous execution and the return type.

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)

fetch_async() → PollingOperation[UserDefinedFunction]

An asynchronous version of fetch().

Refer to PollingOperation for 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:

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 PollingOperation for more information on asynchronous execution and the return type.