snowflake.core.task.TaskCollection | Snowflake Documentation (original) (raw)

DeveloperSnowflake Python APIsSnowflake Python APIs referencetasktask.TaskCollection

class snowflake.core.task.TaskCollection(schema: SchemaResource)

Bases: SchemaObjectCollectionParent[TaskResource]

Represents the collection operations of the Snowflake Task resource.

With this collection, you can create, iterate through, and search for task that you have access to in the current context.

Examples

task_collection = root.databases["mydb"].schemas["myschema"].tasks task = Task( ... name="mytask", ... definition="select 1" ... ) task_collection.create(task)

Attributes

database

The DatabaseResource this collection belongs to.

root

The Root object this collection belongs to.

Methods

create(task: Task, *, mode: CreateMode = CreateMode.error_if_exists) → TaskResource

Create a task in Snowflake.

Parameters:

Examples

Creating a task in Snowflake and getting a reference to it:

task_parameters = Task( ... name="mytask", ... definition="select 1" ... )

Use the task collection created before to create a reference to the task resource

in Snowflake.

task_reference = task_collection.create(task_parameters)

create_async(task: Task, *, mode: CreateMode = CreateMode.error_if_exists) → PollingOperation[TaskResource]

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, starts_with: str | None = None, limit: int | None = None, from_name: str | None = None, root_only: bool = False) → Iterator[Task]

Iterate through Task objects in Snowflake, filtering on any optional like pattern.

Parameters:

Examples

Showing all tasks that you have access to see:

tasks = task_collection.iter()

Showing information of the exact task you want to see:

tasks = task_collection.iter(like="your-task-name")

Showing tasks starting with ‘your-task-name-‘:

tasks = task_collection.iter(like="your-task-name-%")

Using a for loop to retrieve information from iterator:

for task in tasks: ... print(task.name, task.comment)

iter_async(*, like: str | None = None, starts_with: str | None = None, limit: int | None = None, from_name: str | None = None, root_only: bool = False) → PollingOperation[Iterator[Task]]

An asynchronous version of iter().

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

keys() → KeysView[str]

values() → ValuesView[T]