What you will be able to do
- Create scheduled and stream-triggered tasks, and bring them from suspended to running
- Choose between serverless and user-managed compute for a task
- Chain tasks into a task graph and control what happens when runs fail
- Prepare data for report consumers with secure views and future grants
1.Building repeatable refreshes with tasks
A report is only as current as the tables it reads. Tasks are how Snowflake keeps those tables current without anyone running SQL by hand. A task can run SQL statements or stored procedures. It runs either on a schedule or when an event happens, such as new data arriving in a stream.
For a fixed schedule, set the SCHEDULE parameter to an interval such as '60 MINUTES'. To run at particular times or on particular days, use a USING CRON expression with a time zone. Snowflake runs only one instance of a scheduled task at a time. If a run is still going when the next scheduled time arrives, that scheduled time is skipped.
CREATE TASK SCHEDULED_T1
WAREHOUSE='COMPUTE_WH'
SCHEDULE='60 MINUTES'
AS SELECT 1;Sometimes new data arrives at unpredictable times. In that case a triggered task is a better fit. It runs when SYSTEM$STREAM_HAS_DATA reports new rows in a stream, so nothing has to poll the source repeatedly, and data is processed as soon as it lands.
CREATE TASK triggered_task_stream
WHEN SYSTEM$STREAM_HAS_DATA('orders_stream')
AS
INSERT INTO completed_promotions
SELECT order_id, order_total, order_time, promotion_id
FROM orders_stream;Creating a task does not start it. Every new task starts out suspended. EXECUTE TASK runs it once, which is the way to test it. ALTER TASK … RESUME lets it follow its schedule or watch for events from then on. Any outside service that can sign in to your account and is allowed to run SQL can also call EXECUTE TASK. That lets an external pipeline start a Snowflake task.
Checkpoint 1 of 6· Put it in order
Put the documented steps for bringing a new task into production in order
- 1.Refine the task with ALTER TASK
- 2.Define the task with CREATE TASK
- 3.Test it manually with EXECUTE TASK
- 4.Let it run continuously with ALTER TASK … RESUME
- 5.Monitor task costs
The task workflow is: define, test once, resume, monitor, then refine. Testing comes before resuming because a new task starts suspended.
“Manually test tasks using EXECUTE TASK.”Source: docs.snowflake.com
Sources1
2.Serverless or user-managed compute
Every task needs compute. The WAREHOUSE parameter decides which kind. Leave it out and the task is serverless: Snowflake predicts the resources each run needs, based on recent runs, and assigns them automatically. You can limit the size with SERVERLESS_TASK_MIN_STATEMENT_SIZE and SERVERLESS_TASK_MAX_STATEMENT_SIZE. Include WAREHOUSE and the task is user-managed: it runs on a warehouse you choose and size yourself. For either model, the role that runs the task needs the global EXECUTE MANAGED TASK privilege.
| Factor | Serverless tasks | User-managed tasks |
|---|---|---|
| Billing | Based on the actual compute used | Based on warehouse size, with a 60-second minimum each time the warehouse resumes |
| Workload fit | Under-used warehouses, few tasks running at once, fairly stable runs | Fully used warehouses with many tasks running at once, or unpredictable loads |
| Schedule adherence | Recommended when staying on schedule really matters. Snowflake scales up compute if a run goes past its interval | Recommended when staying on schedule matters less |
| Size ceiling | Equivalent to an XXLARGE warehouse at most | Any warehouse size you provision |
Checkpoint 2 of 6· Exam question
A finance team has a task graph in which a root task loads raw orders, and two child tasks build aggregate tables afterwards. The analyst wants each child to start only when the root run completes successfully. What is the correct way to define the children?
Correct answer: D — Create each child with `AFTER root_task` and no `SCHEDULE` of its own, so the root run triggers it on completion.
- A. Independent schedules create separate runs that are not tied to the graph run, so ordering and success dependencies are not guaranteed.
- B. A time offset is not a dependency; if the root runs longer than the offset, the child starts against partially loaded data.
- C. A stream condition reacts to new data and does not wait for the root task to finish, so the aggregate could run mid-load.
- D. Child tasks declare predecessors with `AFTER`; only the root task carries a schedule and the run of the graph flows from it.
Checkpoint 3 of 6· Check yourself
A nightly refresh task needs more compute than an XXLARGE warehouse provides. Which setup works?
Serverless tasks cannot go beyond XXLARGE. For bigger workloads, the documentation says to use a user-managed task on a warehouse of the size you need.
“If a task workload requires a larger warehouse, create a user-managed task with a warehouse of the required size.”Source: docs.snowflake.com
Sources1
3.Chaining refresh steps and handling failures
A reporting refresh often has several steps: load the data, then build the aggregates, then clean up. A task graph runs those steps in order. Its root task sets the schedule. Each child task names its parents with AFTER. Children that share a parent run in parallel. A task with several parents waits until all of them finish. An optional finalizer task, created with FINALIZE, runs after everything else and can clean up or send notifications. All tasks in a graph must have the same owner and be in the same database and schema.
Checkpoint 4 of 6· Fill the gap
task_c must run only after both task_a and task_b finish. Which keyword completes the definition?
CREATE TASK task_c
? task_a, task_b
AS SELECT 1;AFTER names the parent tasks. A task with several parents waits for all of them to complete before it starts.
Source: docs.snowflake.comUnattended jobs need protection against failure. SUSPEND_TASK_AFTER_NUM_FAILURES automatically suspends a task after the given number of consecutive failed or timed-out runs. This stops a broken task from using credits over and over. Task graphs default to suspending after 10 consecutive failures. TASK_AUTO_RETRY_ATTEMPTS retries a failed task. It is off by default. Set on a root task, it retries the whole graph straight away when a child fails. To change a task inside a scheduled graph, suspend the root task first. A run already in progress will finish, and the child tasks don't need to be suspended one by one.
4.Operationalizing data for report consumers
Once tasks keep the data fresh, consumers need a stable and governed way to read it. Two tools from the access-control docs handle this.
The first is a secure view. Create one with the SECURE keyword on CREATE VIEW. Only users granted the role that owns the view can see its definition. Other users who run SHOW VIEWS, call GET_DDL, or query the Information Schema VIEWS view do not get the definition. That lets you show curated metrics without revealing the logic and base tables behind them.
The second tool is a future grant, which handles a reporting schema that keeps gaining tables. A future grant sets privileges that are applied automatically to each new object of a given type as it is created. Pair it with a grant on ALL existing objects, and the BI role can read today's tables and every table added later.
-- Grant the SELECT privilege on all new tables in a schema to role R2
GRANT SELECT ON FUTURE TABLES IN SCHEMA s1 TO ROLE r2;
-- Grant the SELECT privilege on all existing tables in a schema to role R2
GRANT SELECT ON ALL TABLES IN SCHEMA s1 TO ROLE r2;Checkpoint 5 of 6· Exam question
A new task named `REFRESH_KPI` was created with a valid `SCHEDULE`, and the owner role holds all privileges. Hours later, the task history shows no runs at all. What is the most likely cause?
Correct answer: B — The task was created in a suspended state and has never been enabled with `ALTER TASK REFRESH_KPI RESUME`.
- A. A suspended warehouse is resumed automatically by a task run with auto-resume enabled, so auto-suspend does not block scheduling.
- B. Tasks are created suspended, so they never execute on their schedule until the owner resumes them.
- C. Running a task requires usage on the warehouse and `EXECUTE TASK`; `MONITOR` only affects visibility of query activity.
- D. A task with an invalid schedule is rejected at creation; it is not accepted and then silently ignored.
Checkpoint 6 of 6· Match them up
Match each requirement to the feature that meets it
Tap a term, then the definition that fits it.
Secure views hide their definitions from unauthorized users. FUTURE grants cover objects not yet created, and ALL grants cover existing ones, so you need both to cover a schema completely.
“Using the ON FUTURE keywords for new tables and the ALL keyword for existing tables, few SQL statements are required”Source: docs.snowflake.com
Exam traps
Each one states something that sounds right. Open it to see what is actually true.
1.A task starts running on its schedule as soon as CREATE TASK succeeds.Why is that wrong?
New tasks are created suspended. They only follow their schedule after ALTER TASK … RESUME. EXECUTE TASK runs them once.
Covered in Building repeatable refreshes with tasks
2.GRANT SELECT ON ALL TABLES IN SCHEMA also covers tables created after the grant.Why is that wrong?
ALL covers only tables that exist when you run it. A FUTURE grant is what gives privileges automatically on new objects.
Covered in Operationalizing data for report consumers
Practise it for real
Create an hourly refresh task, test it, and switch it on
1.Run CREATE TASK SCHEDULED_T1 with WAREHOUSE='COMPUTE_WH' and SCHEDULE='60 MINUTES' AS SELECT 1;
Why: Including WAREHOUSE makes this a user-managed task with a fixed hourly schedule.
You should see: The task is created in a suspended state.
2.Run EXECUTE TASK SCHEDULED_T1;
Why: A single manual run checks the task before it goes live.
You should see: One run of the task appears in the task history.
3.Run ALTER TASK SCHEDULED_T1 RESUME;
Why: Tasks only follow their schedule once they are resumed.
You should see: The task now runs every 60 minutes.
4.Run ALTER TASK SCHEDULED_T1 SET SUSPEND_TASK_AFTER_NUM_FAILURES = 3;
Why: Automatic suspension stops a broken refresh from using credits again and again.
You should see: After three consecutive failed or timed-out runs, the task suspends itself.
Stuck? Get a nudge
If nothing happens on the hour, check whether you ran RESUME. A new task stays suspended until you do.
Sources
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
“Tasks can run at scheduled times or can be triggered by events, such as when new data arrives in a stream.”
↩︎ Building repeatable refreshes with tasks“If a task is still running when the next scheduled run time occurs, then that scheduled time is skipped.”
↩︎ Building repeatable refreshes with tasks“it eliminates frequent polling of the source when new data arrival is unpredictable.”
↩︎ Building repeatable refreshes with tasks“Serverless tasks: Snowflake predicts resources that are needed and assigns them automatically.”
↩︎ Serverless or user-managed compute“For user-managed tasks, billing for warehouses is based on warehouse size, with a 60-second minimum each time the warehouse is resumed.”
↩︎ Serverless or user-managed compute“The automatic task retry is disabled by default.”
↩︎ Chaining refresh steps and handling failures“When a task is created, it starts as suspended.”
↩︎ Exam trap 1“Manually test tasks using EXECUTE TASK.”
↩︎ Checkpoint“If a task workload requires a larger warehouse, create a user-managed task with a warehouse of the required size.”
↩︎ Checkpoint - 2.
“When multiple child tasks have the same parent, the child tasks run in parallel.”
↩︎ Chaining refresh steps and handling failures“By default, a task graph is suspended after 10 consecutive failures.”
↩︎ Chaining refresh steps and handling failures - 3.
“The definition of a secure view is only exposed to authorized users”
↩︎ Operationalizing data for report consumers“To create a secure view, specify the SECURE keyword in the CREATE VIEW or CREATE MATERIALIZED VIEW command.”
↩︎ Operationalizing data for report consumers - 4.
“As new objects are created, the defined privileges are automatically granted to a role, simplifying grant management.”
↩︎ Operationalizing data for report consumers“As new objects are created, the defined privileges are automatically granted to a role, simplifying grant management.”
↩︎ Exam trap 2“Using the ON FUTURE keywords for new tables and the ALL keyword for existing tables, few SQL statements are required”
↩︎ Checkpoint