snowflake.core.task.TaskCollection¶
- class snowflake.core.task.TaskCollection(schema: SchemaResource)¶
Bases:
SchemaObjectCollectionParent
[TaskResource
]Represents the collection operations of the Snowflake Task resource.
Example
>>> tasks: TaskCollection = root.databases["mydb"].schemas["myschema"].tasks >>> mytask = tasks.create(Task("mytask", definition="select 1")) # returns a TaskResource instance. >>> task_iter = tasks.iter(like="my%")
Attributes
- database¶
- root¶
Methods
- __init__(schema: SchemaResource) None ¶
- create(task: Task, *, mode: Literal['errorifexists'] | Literal['orreplace'] | Literal['ifnotexists'] = 'errorifexists') TaskResource ¶
Create a task in the Snowflake database.
- Parameters:
task – an instance of
Task
.mode –
One of the following strings.
- ”errorifexists”: Throw an
snowflake.core.exceptions.ConflictError
if the task already exists in Snowflake. Equivalent to SQL
create task <name> ...
.- ”orreplace”: Replace if the task already exists in Snowflake. Equivalent to SQL ``create or replace task
<name> …``.
- ”ifnotexists”: Do nothing if the task already exists in Snowflake. Equivalent to SQL ``create task
<name> if not exists…``
Default value is “errorifexists”.
- ”errorifexists”: Throw an
- create_or_update(task: Task) TaskResource ¶
Create or update a task in the Snowflake database.
The Snowflake task’s properties will be updated to the properties of the input
task
if the task already exists. Note that the full picture of a task is expected. If a property isn’t set a value in the inputtask
, the property will be set toNULL
in Snowflake too because it’s regarded as the expected value.- Parameters:
task – an instance of
Task
.
Example
>>> from snowflake.core import Root >>> root = Root(connection) >>> tasks: TaskCollection = root.databases["mydb"].schemas["myschema"].tasks >>> mytask = tasks.create(Task("mytask", definition="select 1")) >>> mytask_entity = mytask.fetch() >>> mytask_entity.definition = "select 2" >>> tasks.create_or_update(mytask_entity)
- items() ItemsView[str, T] ¶
- iter(*, like: str | None = None, startswith: str | None = None, limit: int | None = None, from_name: str | None = None, root_only: bool = False) PagedIter[Task] ¶
Search for tasks in Snowflake.
- Parameters:
like – The pattern of the Task name. Use
%
to represent any number of characters and?
for a single character.startswith – The task name starts with this string.
root_only – Look for root tasks only.
- keys() KeysView[str] ¶
- values() ValuesView[T] ¶