snowflake.core.function.FunctionResourceยถ

class snowflake.core.function.FunctionResource(name_with_args: Annotated[str, Strict(strict=True)], collection: FunctionCollection)ยถ

Bases: SchemaObjectReferenceMixin[FunctionCollection]

Represents a reference to a Snowflake function.

With this function reference, you can create and fetch information about functions, as well as perform certain actions on them.

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

delete(if_exists: bool = False) โ†’ Noneยถ

The delete() method is deprecated; use drop() instead.

Delete this function.

if_exists: bool, optional

Whether to error if the function doesnโ€™t exist. Default is False.

Deleting a function using its reference, erroring if it doesnโ€™t exist:

>>> function_reference.delete()
Copy

Deleting a function using its reference, if it exists:

>>> function_reference.delete(if_exists=True)
Copy
drop(if_exists: bool = False) โ†’ Noneยถ

Drop this function.

Parameters:

if_exists (bool, optional) โ€“ Whether to error if the function doesnโ€™t exist. Default is False.

Examples

Dropping a function using its reference, erroring if it doesnโ€™t exist:

>>> function_reference.drop()
Copy

Dropping a function using its reference, if it exists:

>>> function_reference.drop(if_exists=True)
Copy
drop_async(if_exists: bool = False) โ†’ PollingOperation[None]ยถ

An asynchronous version of drop().

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

execute(input_args: list[Any] | None = None) โ†’ Anyยถ

Execute this function.

Parameters:

input_args (list[Any], optional) โ€“ A list of arguments to pass to the function. The number of arguments must match the number of arguments the function expects.

Examples

Executing a function using its reference:

>>> function_reference.execute(input_args=[1, 2, "word"])
Copy
execute_async(input_args: list[Any] | None = None) โ†’ PollingOperation[Any]ยถ

An asynchronous version of execute().

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

fetch() โ†’ Functionยถ

Fetch the details of a function.

Examples

Fetching a reference to a function to print its name:

>>> function_reference = root.databases["my_db"].schemas["my_schema"].functions["foo(REAL)"]
>>> my_function = function_reference.fetch()
>>> print(my_function.name)
Copy
fetch_async() โ†’ PollingOperation[Function]ยถ

An asynchronous version of fetch().

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