What you will be able to do
- Choose between a serverless task and a user-managed task for a given workload, and configure each one
- Set up interval, CRON and stream-triggered schedules, and start, suspend and retry task graphs
- Grant the minimum privileges needed to create, own, run, operate and view tasks
- Use TASK_HISTORY and SHOW TASKS to find out why a task did not run, how long it waited, and why it failed or timed out
Key concept
Task owner role — A task does not run as the person who created it. It runs as a system service with the privileges of the role that owns it. That role must hold the run-time privileges, and the task must be resumed, before any scheduled run happens.
1.Serverless and user-managed tasks
A task is a Snowflake object that runs SQL, a stored procedure call or Snowflake Scripting on a schedule or when an event happens. It replaces the external cron job that used to drive a data pipeline. Every run needs compute, and you choose where that compute comes from when you define the task. Serverless tasks get compute that Snowflake predicts and assigns. User-managed tasks run on a virtual warehouse that you name.
The WAREHOUSE parameter decides which model you get. Leave it out and the task is serverless. Include it and the task runs on that warehouse. For a serverless task, Snowflake bases its sizing on a dynamic analysis of the task's most recent runs. When a schedule is set, it resizes so that future runs finish within that time frame.
CREATE TASK SCHEDULED_T1
SCHEDULE='60 MINUTES'
AS SELECT 1;A brand-new serverless task has no history yet, so Snowflake can't predict a size for it. USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE sets the size for the first runs. If you leave it out, those runs use MEDIUM. After a few successful runs, Snowflake ignores the setting and sizes from history instead. Setting it together with WAREHOUSE produces a user error, because the parameter applies only to serverless tasks. Two more parameters set limits for later runs. SERVERLESS_TASK_MIN_STATEMENT_SIZE (default XSMALL) gives a floor for predictable performance, and SERVERLESS_TASK_MAX_STATEMENT_SIZE (default XXLARGE) gives a ceiling against unexpected costs.
Serverless compute has a hard upper limit: XXLARGE. A workload that needs a larger warehouse has to be a user-managed task on a warehouse of that size. In return, a user-managed task gives you full control of the compute. That control comes with the job of sizing the warehouse, and if the warehouse is shared, you have to think about how the task affects the other workloads on it.
| Factor | Serverless task | User-managed task |
|---|---|---|
| How it is defined | Omit WAREHOUSE; optionally set USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE | Include WAREHOUSE |
| Billing | Actual compute resource usage | Warehouse size, with a 60-second minimum each time the warehouse resumes |
| Workload fit | Under-utilized warehouses, quick or relatively stable runs | Fully utilized warehouses with multiple concurrent tasks, unpredictable loads on the warehouse |
| Schedule adherence | Highly important; Snowflake grows compute when a run exceeds the interval | Less important |
| Maximum size | Equivalent to XXLARGE | Whatever warehouse you choose |
Take a MERGE that runs every five minutes and has no warehouse of its own. If you size a dedicated warehouse for it, you pay at least 60 seconds each time it resumes, and you have to pick a size for the worst run. If you put it on a busy shared warehouse, it competes with every other query there. A serverless task avoids both problems: you pay for the compute it actually uses, and Snowflake resizes after each run. User-managed wins in the opposite case, where a warehouse already runs many concurrent tasks at full utilization and adding one more costs almost nothing. "Unpredictable loads" in the table means unpredictable demand on a shared warehouse, not one task whose run time varies.
Checkpoint 1 of 9· Fill the gap
This hourly task must run on the existing COMPUTE_WH virtual warehouse, not on Snowflake-managed compute. Which parameter completes the definition?
CREATE TASK SCHEDULED_T1
? ='COMPUTE_WH'
SCHEDULE='60 MINUTES'
AS SELECT 1;The WAREHOUSE parameter is what makes a task user-managed. The other three parameters only apply to serverless tasks and set sizes, not a warehouse to run on. Combining USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE with WAREHOUSE even produces a user error.
Source: docs.snowflake.comCheckpoint 2 of 9· Check yourself
A nightly transformation task needs more compute than an XXLARGE warehouse provides. How should it be configured?
Serverless compute can never go above XXLARGE, and no parameter changes that limit. A workload that needs more must run as a user-managed task on a warehouse of that size.
“If a task workload requires a larger warehouse, create a user-managed task with a warehouse of the required size.”Source: docs.snowflake.com
Checkpoint 3 of 9· Exam question
A pipeline runs a MERGE statement every 5 minutes. Run time varies from 10 seconds to 20 minutes depending on upstream volume, and no warehouse is dedicated to the job. The administrator wants to avoid sizing a warehouse or paying for idle warehouse time. Which approach is MOST appropriate?
Correct answer: A — Create a serverless task by omitting the WAREHOUSE parameter and setting an initial size so Snowflake-managed compute adapts to later runs.
- A. Correct: a serverless task has no WAREHOUSE; Snowflake picks and resizes compute from run history and bills only the compute used, which suits short or highly variable jobs. The initial size setting only seeds the first runs.
- B. Incorrect: a dedicated XSMALL warehouse still needs manual sizing, which is too small for the 20-minute runs, and each resume incurs the 60-second minimum plus the idle auto-suspend period.
- C. Incorrect: running on the shared X-LARGE warehouse spends credits at a high rate for tiny runs and competes with BI queries, so it does not remove the sizing or cost concern.
- D. Incorrect: a multi-cluster warehouse scales for concurrent queries, not for one task's run time, and a task without overlapping runs would not use extra clusters while still paying for warehouse time.
2.Schedules, stream triggers and the suspended start
The SCHEDULE parameter takes one of two forms. An interval such as '10 SECONDS', '60 MINUTES' or '1 HOUR' repeats at a fixed spacing. A CRON expression with a time zone, such as 'USING CRON 7 3 * * SUN America/Los_Angeles', runs at a specific time or day: here, every Sunday at 3:07 a.m. Pacific. You can set either form in CREATE TASK or change it later with ALTER TASK.
That rule is a reason to pick serverless when keeping to the schedule matters. A serverless task that overruns its interval gets more compute on the next run, while a user-managed task keeps missing slots until someone resizes its warehouse. More compute shortens some SQL but not all of it, so it doesn't guarantee that a run finishes in its window.
A triggered task runs on an event instead of the clock. A WHEN SYSTEM$STREAM_HAS_DATA('orders_stream') condition runs the task when the stream has new rows. This suits ELT where new data arrives at unpredictable times: you don't keep polling the source, and the data is processed as soon as it lands. Serverless triggered tasks require a TARGET_COMPLETION_INTERVAL, which sets the time Snowflake scales compute to finish within. If you combine a schedule with a WHEN condition, the condition is checked on each scheduled run.
CREATE TASK triggered_task_stream
SCHEDULE = '1 HOUR'
WHEN SYSTEM$STREAM_HAS_DATA('orders_stream')
AS SELECT 1;Every new task is created suspended, including cloned tasks. A task with a valid schedule and fully privileged owner still does nothing until someone runs ALTER TASK … RESUME, which lets it follow its schedule or watch for events. EXECUTE TASK runs it once, which is how you test a task. It does not start the schedule, and a schedule doesn't need a manual run before it starts. When a task is resumed, Snowflake checks that the owner role has the privileges it needs to run the task. To change a task later, use ALTER TASK, or CREATE OR ALTER TASK to define its target state in one statement.
Checkpoint 4 of 9· Check yourself
Two hours after a data engineer ran CREATE TASK with SCHEDULE='60 MINUTES', TASK_HISTORY shows no runs at all. The owner role already holds every privilege it needs. What must the engineer do so the task runs on its schedule?
New tasks are always created suspended, so the schedule never runs until ALTER TASK … RESUME. EXECUTE TASK runs the task only once and does not start the schedule.
“it starts as suspended. To allow a task to follow a schedule or detect events continuously, use ALTER TASK … RESUME.”Source: docs.snowflake.com
Checkpoint 5 of 9· Exam question
A developer ran CREATE TASK with SCHEDULE = '5 MINUTE' using a role that has every required privilege. An hour later TASK_HISTORY shows no runs for the task. What is the MOST likely cause and fix?
Correct answer: A — The task was created in a suspended state, so the owner role, which also holds EXECUTE TASK, must run ALTER TASK ... RESUME to start scheduling.
- A. Correct: tasks are created suspended and are only scheduled after ALTER TASK ... RESUME, which requires the owner role to hold the account-level EXECUTE TASK privilege.
- B. Incorrect: an interval schedule does not wait for a manual run; once a task is resumed, the scheduler triggers it on its own.
- C. Incorrect: ALLOW_OVERLAPPING_EXECUTION only affects what happens when a prior run is still going; it cannot block a first run that was never scheduled.
- D. Incorrect: tasks resume their warehouse automatically when they run, and no manual warehouse resume or OPERATE grant is needed.
Sources1
3.Building and operating task graphs
A task graph (a directed acyclic graph, or DAG) chains tasks into a workflow. It has one root task, dependent child tasks, and no loops. Only the root carries the schedule or trigger. Each child names its parents with AFTER. Children that share a parent run in parallel, and a child with several parents waits until all of them succeed.
CREATE TASK task_root
SCHEDULE = '1 MINUTE'
AS SELECT 1;
CREATE TASK task_a
AFTER task_root
AS SELECT 1;
CREATE TASK task_b
AFTER task_root
AS SELECT 1;
CREATE TASK task_c
AFTER task_a, task_b
AS SELECT 1;A graph has structural limits. It can hold at most 1000 tasks, and each task can have at most 100 parents and 100 children. Every task in the graph must have the same owner and live in the same database and schema. If you transfer ownership of a single task, that task loses its links to its parents and children. To transfer a whole graph and keep its links, use GRANT OWNERSHIP on all tasks in the schema, or drop the owning role. You can attach an optional finalizer, created with CREATE TASK … FINALIZE = task_root, which runs after all other tasks complete or fail. Use it for cleanup or notifications. Each root can have only one finalizer, and a finalizer can't have children.
To start a graph, resume each child task (including the finalizer) and then resume the root. Or call SYSTEM$TASK_DEPENDENTS_ENABLE on the root, which resumes every task in the graph at once. To change a task in a running graph, suspend the root first. The run already in progress finishes, and future scheduled runs are cancelled. The children keep their state, so resuming the root alone restarts the graph. To leave one step out, suspend that child: the graph continues as though it had succeeded. To list all tasks in a graph, pass the root to the TASK_DEPENDENTS table function.
Failures spread through a graph. If any child fails, the whole graph run counts as failed, and the children of a failed parent are skipped. EXECUTE TASK … RETRY LAST reruns the latest graph run from the task that failed. Setting TASK_AUTO_RETRY_ATTEMPTS on the root retries the whole graph straight away instead of waiting for the next scheduled run. After 10 consecutive failures, a graph is suspended. Change that number with SUSPEND_TASK_AFTER_NUM_FAILURES on the root.
Resume each child task you want in the run, including the finalizer. Then run EXECUTE TASK on the root. The resumed children run in graph order, and the root's schedule stays off because the root itself was never resumed.
Checkpoint 6 of 9· Fill the gap
You want to add a cleanup step to the graph built from task_root, task_a, task_b and task_c. It must run once after all other tasks in the graph complete or fail. Which task name completes the finalizer definition?
CREATE TASK task_finalizer
FINALIZE = ?
AS SELECT 1;A finalizer always belongs to the root task. It is created with FINALIZE set to the root task's name, and each root can have only one finalizer. It is not attached to the last child, because it runs after every other task in the graph completes or fails.
Source: docs.snowflake.comSources3
4.Privileges to create, run, operate and view tasks
Creating a task and running it need different sets of privileges. Creating one is ordinary object creation in a schema. Running one depends on the owner role holding account-level grants, which are covered under Account-level (global) privileges. For tasks, two of those grants matter: the owner role needs EXECUTE TASK before any task it owns can run, and also EXECUTE MANAGED TASK if the task is serverless.
| Object | To create the task | For the owner to run the task |
|---|---|---|
| Account | EXECUTE MANAGED TASK (serverless only) | EXECUTE TASK; plus EXECUTE MANAGED TASK (serverless only) |
| Database | USAGE | USAGE |
| Schema | USAGE, CREATE TASK | USAGE |
| Task | — | USAGE |
| Warehouse | USAGE (user-managed only) | USAGE (user-managed only) |
The owner role also needs every privilege the task's own SQL needs, such as INSERT on the target table. A role that only creates serverless tasks never needs a warehouse grant. A role that creates user-managed tasks never needs EXECUTE MANAGED TASK. A common setup grants the account-level privileges to a custom role and then grants that role to the task-owning roles. To stop a role's tasks from running, revoke that custom role. Revoking EXECUTE TASK prevents all subsequent runs from starting under that role.
USE ROLE accountadmin;
GRANT EXECUTE TASK, EXECUTE MANAGED TASK ON ACCOUNT TO ROLE taskadmin;Some people need to operate or inspect tasks without owning them:
- Operating: a role with
OPERATEon the task, plus USAGE on its database and schema, can suspend and resume it. It needs nothing else. - Viewing: you can see tasks if you have the ACCOUNTADMIN role, OWNERSHIP of the task, or the global
MONITOR EXECUTIONprivilege. MONITOR EXECUTION is for viewing only and plays no part in creating tasks. - Identity: by default, a task runs as a system service, not as a user. A dropped or locked user therefore doesn't stop it.
EXECUTE AS USERruns it as a named user instead, which requires the owner role to hold IMPERSONATE on that user.
Dropping a task's owner role transfers ownership to the role that ran DROP ROLE, and the task pauses. No new runs are scheduled until the new owner resumes it. A run already in progress finishes under the dropped role.
Checkpoint 7 of 9· Match them up
Each privilege below gives a role a different ability over tasks. Match each one to what it allows or when it is required.
Tap a term, then the definition that fits it.
Every task owner needs EXECUTE TASK to run anything. On top of that, each compute model needs exactly one more grant: EXECUTE MANAGED TASK for serverless tasks, or warehouse USAGE for user-managed tasks, never both. OPERATE lets a non-owner role suspend and resume a task, and MONITOR EXECUTION lets a role view tasks only.
“Account | EXECUTE MANAGED TASK | Required only for tasks that rely on serverless compute resources.”Source: docs.snowflake.com
Checkpoint 8 of 9· Exam question
A role named etl_dev must be able to create (but not yet run) a serverless task in schema ETL.JOBS. Select THREE privileges that the role needs for this.(Select 3)
Correct answers: A, B, C — CREATE TASK on schema ETL.JOBS so the role may define new task objects in the schema.; EXECUTE MANAGED TASK on the account so the role may create tasks that use Snowflake-managed compute.; USAGE on database ETL and on schema ETL.JOBS so the role can reach the schema where the task is created.
- A. Correct: CREATE TASK on the schema is the object-level privilege required to create any task, serverless or not.
- B. Correct: EXECUTE MANAGED TASK is the account-level privilege that allows a role to create serverless tasks that run on Snowflake-managed compute.
- C. Correct: the role needs USAGE on the parent database and schema to resolve the location where the task is created.
- D. Incorrect: a serverless task has no warehouse, so warehouse USAGE is a requirement for user-managed tasks only.
- E. Incorrect: MONITOR EXECUTION only lets a role view task and pipe executions; it does not grant the ability to create tasks.
Sources1
5.Troubleshooting runs with TASK_HISTORY
When a task doesn't do what you expected, start with the history before changing anything. Query the TASK_HISTORY table function to see whether the task ran at all. A task can run successfully while the SQL inside it fails, so note the scheduled and completed times and any error code and message. In the Account Usage TASK_HISTORY view, completed runs show a STATE of SUCCEEDED, FAILED, CANCELLED or SKIPPED. That view leaves out runs that are still scheduled or executing, which only the Information Schema table function returns.
If the history shows no runs, work through these causes in order:
- The task is still suspended. Check its state with SHOW TASKS or DESCRIBE TASK, then run ALTER TASK … RESUME, or SYSTEM$TASK_DEPENDENTS_ENABLE for a whole graph.
- The schedule hasn't come round yet. Check the cron expression and confirm that at least one scheduled time has passed.
- The owner role is missing a privilege. Use SHOW GRANTS TO ROLE to check that it has EXECUTE TASK and the USAGE grants.
- The trigger had nothing to act on. For a SYSTEM$STREAM_HAS_DATA condition, confirm that the stream had change records when the task was last scheduled.
- A predecessor failed. Children of a failed parent are skipped.
The history also shows how long each run took, split into two parts. Queuing time runs from SCHEDULED_TIME to QUERY_START_TIME and is the time spent waiting for compute. Execution time runs from QUERY_START_TIME to COMPLETED_TIME. Long queuing on a user-managed task usually means its warehouse is shared or busy. Serverless tasks count queuing time against their target completion interval and scale to cover it.
Each run has a 60-minute default limit, which protects against tasks that never finish. A timed-out run always shows as FAILED in the task history. How the different timeout parameters interact is covered in Timeout parameters. For tasks, the practical fix has three options. First check whether a custom limit is already set. If the warehouse is undersized, increase it. Otherwise raise the limit with ALTER TASK … SET USER_TASK_TIMEOUT_MS = <num>. Neither fix helps if the SQL has query parallelization issues. In that case, rewrite the statement.
SHOW PARAMETERS LIKE 'USER_TASK_TIMEOUT_MS' IN TASK <task_name>;Checkpoint 9 of 9· Fill the gap
Several runs of a nightly task appear as FAILED in TASK_HISTORY, each about 60 minutes after it started. Before raising any limit, you want to see whether the task already has a custom run timeout. Which parameter name completes the statement?
SHOW PARAMETERS LIKE ' ? ' IN TASK <task_name>;USER_TASK_TIMEOUT_MS sets the per-run time limit. A timed-out run always shows as FAILED, so runs that fail at about 60 minutes point to the default 3600000 ms timeout. If the statement returns no row, that default applies. The other parameters set a scaling target, a suspension threshold and a size ceiling, not a run timeout.
Source: docs.snowflake.comSources
(5)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.https://docs.snowflake.com/en/user-guide/tasks-introOfficial docs
“Serverless tasks: Snowflake predicts resources that are needed and assigns them automatically.”
↩︎ Serverless and user-managed tasks“For user-managed tasks, billing for warehouses is based on warehouse size, with a 60-second minimum each time the warehouse is resumed.”
↩︎ Serverless and user-managed tasks“For serverless tasks, Snowflake bills your account based on the actual compute resource usage.”
↩︎ Serverless and user-managed tasks“If a task is still running when the next scheduled run time occurs, then that scheduled time is skipped.”
↩︎ Schedules, stream triggers and the suspended start“A target completion interval is required for serverless triggered tasks.”
↩︎ Schedules, stream triggers and the suspended start“When a task is created, it starts as suspended.”
↩︎ Schedules, stream triggers and the suspended start“Revoking the EXECUTE TASK privilege on a role prevents all subsequent task runs from starting under that role.”
↩︎ Privileges to create, run, operate and view tasks“In addition to the task owner, a role that has the OPERATE privilege on the task can suspend or resume the task.”
↩︎ Privileges to create, run, operate and view tasks“When a task transfers ownership, it is automatically paused and new task runs aren’t scheduled until the new owner resumes the task.”
↩︎ Privileges to create, run, operate and view tasks“To calculate queueing time, query TASK_HISTORY view and compare SCHEDULED_TIME with QUERY_START_TIME.”
↩︎ Troubleshooting runs with TASK_HISTORY“The system service runs the task using the same privileges as the task owner.”
↩︎ Key concept“When a task is created, it starts as suspended.”
↩︎ Exam trap 1“Required only for tasks that rely on serverless compute resources.”
↩︎ Exam trap 2“The maximum compute size for a serverless task is equivalent to an XXLARGE virtual warehouse.”
↩︎ Exam trap 3“If a task workload requires a larger warehouse, create a user-managed task with a warehouse of the required size.”
↩︎ Checkpoint“it starts as suspended. To allow a task to follow a schedule or detect events continuously, use ALTER TASK … RESUME.”
↩︎ Checkpoint“Account | EXECUTE MANAGED TASK | Required only for tasks that rely on serverless compute resources.”
↩︎ Checkpoint - 2.
“Omit this parameter to use serverless compute resources for runs of this task.”
↩︎ Serverless and user-managed tasks“If the parameter is omitted, the first runs of the task are executed using a medium-sized (MEDIUM) warehouse.”
↩︎ Serverless and user-managed tasks - 3.
“When multiple child tasks have the same parent, the child tasks run in parallel.”
↩︎ Building and operating task graphs“All tasks in a task graph must have the same task owner and be stored in the same database and schema.”
↩︎ Building and operating task graphs“By default, a task graph is suspended after 10 consecutive failures.”
↩︎ Building and operating task graphs - 4.https://docs.snowflake.com/en/user-guide/tasks-tsOfficial docs
“Query the TASK_HISTORY table function to verify the task did not run.”
↩︎ Troubleshooting runs with TASK_HISTORY“There is a 60 minute default limit on a single run of a task.”
↩︎ Troubleshooting runs with TASK_HISTORY - 5.
“Status of the completed task: SUCCEEDED, FAILED, CANCELLED, or SKIPPED.”
↩︎ Troubleshooting runs with TASK_HISTORY“The timed-out tasks always have a FAILED state in the task history.”
↩︎ Exam trap 4