snowflake.core.function.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ΒΆ
- rootΒΆ
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 optionalmode (CreateMode, optional) β
One of the following enum values.
CreateMode.error_if_exists
: Throw ansnowflake.core.exceptions.ConflictError
if 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 is
CreateMode.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)
- 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)
- keys() KeysView[str] ΒΆ
- values() ValuesView[T] ΒΆ