snowflake.core.function.FunctionCollection | Snowflake Documentation (original) (raw)
DeveloperSnowflake Python APIsSnowflake Python APIs referencefunctionfunction.FunctionCollection
class snowflake.core.function.FunctionCollection(schema: SchemaResource)¶
Bases: SchemaObjectCollectionParent
[FunctionResource]
Represents the collection operations on the Snowflake Function resource.
With this collection, you can create, iterate through, and search for function that you have access to in the current context.
Examples
Creating a function instance:
functions = root.databases["my_db"].schemas["my_schema"].functions new_function = Function( ... name="foo", ... returns="NUMBER", ... arguments=[FunctionArgument(datatype="NUMBER")], ... service="python", ... endpoint="https://example.com", ... path="example.py" ... ) functions.create(new_function)
Attributes
database¶
The DatabaseResource this collection belongs to.
root¶
The Root object this collection belongs to.
Methods
create(function: Function, mode: CreateMode = CreateMode.error_if_exists) → FunctionResource¶
Create a function in Snowflake.
Parameters:
- function (Function) – The
Function
object, together withFunction
’s properties: name, returns, arguments, service, endpoint, path; max_batch_rows is optional - mode (CreateMode, optional) –
One of the following enum values.CreateMode.error_if_exists
: Throw an snowflake.core.exceptions.ConflictErrorif the function already exists in Snowflake. Equivalent to SQLcreate function <name> ...
.CreateMode.or_replace
: Replace if the function already exists in Snowflake. Equivalent to SQLcreate or replace function <name> ...
.CreateMode.if_not_exists
: Do nothing if the function already exists in Snowflake. Equivalent to SQLcreate function <name> if not exists...
Default isCreateMode.error_if_exists
.
Examples
Creating a function, replacing any existing function with the same name:
functions = root.databases["my_db"].schemas["my_schema"].functions new_function = Function( ... name="foo", ... returns="NUMBER", ... arguments=[FunctionArgument(datatype="NUMBER")], ... service="python", ... endpoint="https://example.com", ... path="example.py" ... ) functions.create(new_function, mode=CreateMode.or_replace)
create_async(function: Function, mode: CreateMode = CreateMode.error_if_exists) → PollingOperation[FunctionResource]¶
An asynchronous version of create().
Refer to PollingOperation for more information on asynchronous execution and the return type.
items() → ItemsView[str, T]¶
iter(*, like: str | None = None) → Iterator[Function]¶
Iterate through Function
objects from Snowflake, filtering on any optional ‘like’ pattern.
Parameters:
like (str , optional) – A case-insensitive string functioning as a filter, with support for SQL wildcard characters (% and _).
Examples
Showing all functions that you have access to see:
functions = function_collection.iter()
Showing information of the exact function you want to see:
functions = function_collection.iter(like="your-function-name")
Showing functions starting with ‘your-function-name-‘:
functions = function_collection.iter(like="your-function-name-%")
Using a for loop to retrieve information from iterator:
for function in functions: ... print(function.name)
iter_async(*, like: str | None = None) → PollingOperation[Iterator[Function]]¶
An asynchronous version of iter().
Refer to PollingOperation for more information on asynchronous execution and the return type.
keys() → KeysView[str]¶
values() → ValuesView[T]¶