Task¶
- a scheduled task using either
SCHEDULE <n> MINUTEorCRON <cron>, but not event triggered- A timezone can be specified, BP if DST is observed, do not schedule any tasks between 1-3AM
- tasks are created in suspended state, they must be
alter task ... resume - Task owner must have
USAGEon warehouse and globalEXECUTE TASKprivilege - Only
AccountAdmin, task owner and anyone withmonitor executioncan viewTASK_HISTORY - DAG still runs if some tasks (except root) are suspended. Child tasks run if at least one parent is not suspended and completes
- by default, a runaway task is killed after 60 minutes
- All tasks in a DAG must have same owner, database and schema
- A DAG can have one optional finalizer task which runs after all tasks run. cannot have schedule or child tasks
- Removing a predecessor task, or changing its owner, creates a new root task and tree of its dependents, or a standalone task
- error notifications: Only the root task needs to have
error_integrationspecified; child tasks use the same integration - A child task,
AFTER <parent-task>...cannot have more than 1 root tasks as parent - A finalizer task,
FINALIZE=<root-task>, runs regardless of status of other tasks, and is attached to a root task
| management system fn/sp/vw | purpose |
|---|---|
system$set_return_value() |
(SP) set status for the current task to be retrieved by child tasks |
system$get_predecessor_return_value() |
get status set by the parent task |
system$task_dependents_enable() |
recursively enable children of a root task |
system$user_task_cancel_ongoing_executions() |
cancel task executions |
COMPLETE_TASK_GRAPHS |
fn/vw that records completed graph runs |
TASK_VERSIONS |
a unique version identifies a stand-alone or a DAG |
Attributes¶
- be serverless or have a
WAREHOUSEspecified - optionally can specify session parameters
- optional dependency (ancestor task) using
AFTER - optional condition
WHEN(to check if stream has data) - have
ALLOW_OVERLAPPING_EXECUTIONis set toTRUEon root task to allow multiple concurrent DAGs- multiple root task instances cannot run in parallel -- but only the child tasks of the DAG can
- have a cron schedule that allows time with timezone,
- it is possible for a task to run twice or not at all during time change
SUSPEND_TASK_AFTER_FAILURESallows task to be suspended afternfailures of any child tasks
Serverless¶
- serverless tasks get compute resources based on the execution history, but never larger than
XXLARGE - serverless tasks are not charged by thread, however they are by second (Ref: PS Delivery Enablement 11/12/24)
- BP serverless is ideal for tasks that
- run quickly (< 1 minute), or fewer concurrent tasks to utilize a WH
- are stable (since the compute size is based on previous runs)
- are able to complete withing scheduling interval (otherwise Snowflake will increase WH size)
- Triggered tasks loop runs every 30 seconds or up to 10 seconds (Ref PS Delivery Enablement 11/12/24)