Module 11 · Lesson 8 of 15Detailed study · about 25 min

Schedules, CRON and triggered execution

A schedule decides when to check for work. A triggered task reacts to a supported condition without a polling schedule.

Understand the idea

For scheduled tasks, WHEN can skip a run when there is no change signal. Skipping differs from failing. For triggered tasks, omit SCHEDULE and use a supported condition such as SYSTEM$STREAM_HAS_DATA. Neither choice promises execution at the exact instant a row is inserted.

Key ideas in simple English
ConceptWhat it means
IntervalA repeated time-based opportunity to run.
CRONA calendar expression with an explicit time zone.
WHENA condition checked before the body runs.
Triggered taskUses a trigger condition without SCHEDULE.

A concrete example

Both tasks are suspended. The CRON definition requests the top of each hour in UTC.

Remember: Choose scheduling semantics deliberately and make the real task consume or resolve its work condition.

Explain it step by step · full theory

Understand the concept

For scheduled tasks, WHEN can skip a run when there is no change signal. Skipping differs from failing. For triggered tasks, omit SCHEDULE and use a supported condition such as SYSTEM$STREAM_HAS_DATA. Neither choice promises execution at the exact instant a row is inserted.

CRON uses minute, hour, day-of-month, month and day-of-week fields plus a time zone. UTC avoids daylight-saving ambiguity for a simple hourly lab. Understand time zones before choosing local business schedules.

Walk through the behavior

The examples remain suspended. They write demonstration labels and intentionally do not consume CONSUMER_B. Do not resume the triggered demonstration indefinitely: an unconsumed condition can cause repeated work. The later real task calls a consuming procedure instead.

Serverless triggered tasks require TARGET_COMPLETION_INTERVAL and applicable account privileges. This expresses a target used for managed compute, not a guaranteed end-to-end SLA.

Words used in this lesson
Interval
A repeated time-based opportunity to run.
CRON
A calendar expression with an explicit time zone.
WHEN
A condition checked before the body runs.
Triggered task
Uses a trigger condition without SCHEDULE.

See how it works

Choose a step to explore the idea at your own pace.

Open the interactive explanation
Interactive explainer1 / 3

Schedules, CRON and triggered execution

Source data
Change boundary

Start with the source

A schedule decides when to check for work. A triggered task reacts to a supported condition without a polling schedule.

Automatic playback is off for reduced motion. Select any step or use Previous and Next. Illustrations explain behavior; they are not live measurements.

Read the complete diagram explanation
  1. Start with the source

    A schedule decides when to check for work. A triggered task reacts to a supported condition without a polling schedule.

  2. Follow the work

    For scheduled tasks, WHEN can skip a run when there is no change signal. Skipping differs from failing. For triggered tasks, omit SCHEDULE and use a supported condition such as SYSTEM$STREAM_HAS_DATA. Neither choice promises execution at the exact instant a row is inserted.

  3. Explain the outcome

    Choose scheduling semantics deliberately and make the real task consume or resolve its work condition.

Try the SQL or command

Read → predict → run in your learning environment → compare. You can also learn by reading without an account.

New to SQL? Where to run it and how to read it

A query is a question written in SQL. Snowflake runs it and returns a result table. This website shows examples; it does not connect to your account.

  1. No account yet? Read and predict the output first. Follow the account and Snowsight lesson when you are ready.
  2. For SQL practice, use a learning account in Snowsight and select an authorized role and warehouse. A role determines permissions; a warehouse supplies processing power. Follow the example’s database/schema setup when it refers to stored objects.
  3. Read the entire example, including comments beginning with --. Run the selected statement or labeled block in the stated order. Examples labeled Python, shell or HTTP belong in that client, not in a SQL editor.
  4. Compare values and row counts with the explained result. If an example deliberately causes an error, follow its rollback and cleanup steps before continuing.
SELECT / FROM
Choose the values to return / identify their input.
VALUES / COLUMN1
VALUES supplies tiny example rows. COLUMN1 means their first column, COLUMN2 their second.
AS / WITH
AS gives a result a readable name. WITH names a temporary query step within one statement.
NULL / ::
NULL means missing or unknown. The :: notation converts a value to a named data type.
Session
One connection and its settings. Keep related transaction steps in the same session.
Database.schema.table
A full address for stored data. It is separate from the warehouse that processes queries.

Need the L2_OBJECTS_LAB setup? Open the first database-object lesson →

Help with common practice errors
  • No active warehouse: select a warehouse your role can use. Do not assume you need to create a new one.
  • Object missing or not authorized: check the full name, required setup and active role. Ask the account owner for access if needed.
  • Object already exists: setup may already have run. Read the current state or choose a fresh lab name consistently; do not add OR REPLACE blindly.
  • Different result: check whether an earlier INSERT or UPDATE changed the data. VALUES examples provide their own fresh input for each statement.

Before running this lesson

Manual learning lab; nothing runs on this website. Complete lesson 1 setup in L2_OBJECTS_LAB.M11_LAB and follow the lesson order. Use the same authorized role and warehouse for manual SQL. Task templates use <lab_warehouse>: replace it with an approved warehouse name. Do not activate several consumers against the same stream. Each task starts suspended; running or resuming it can consume compute credits.

Scheduled and calendar templates

SQL · example
CREATE TASK INTERVAL_DEMO WAREHOUSE=<lab_warehouse> SCHEDULE='5 MINUTE'
WHEN SYSTEM$STREAM_HAS_DATA('L2_OBJECTS_LAB.M11_LAB.CONSUMER_B')
AS INSERT INTO L2_OBJECTS_LAB.M11_LAB.TASK_RUN_LOG VALUES ('interval',CURRENT_TIMESTAMP());
CREATE TASK CRON_DEMO WAREHOUSE=<lab_warehouse>
SCHEDULE='USING CRON 0 * * * * UTC'
AS INSERT INTO L2_OBJECTS_LAB.M11_LAB.TASK_RUN_LOG VALUES ('hourly',CURRENT_TIMESTAMP());

What to expect and why

Both tasks are suspended. The CRON definition requests the top of each hour in UTC.

Serverless triggered definition — do not resume this demo

SQL · example
CREATE TASK SERVERLESS_TRIGGER_DEMO TARGET_COMPLETION_INTERVAL='1 MINUTE'
WHEN SYSTEM$STREAM_HAS_DATA('L2_OBJECTS_LAB.M11_LAB.CONSUMER_B')
AS INSERT INTO L2_OBJECTS_LAB.M11_LAB.TASK_RUN_LOG VALUES ('triggered-demo',CURRENT_TIMESTAMP());

What to expect and why

No WAREHOUSE and no SCHEDULE: this demonstrates serverless triggered configuration. Leave suspended because it logs without consuming the stream.

Check your understanding

Choose an answer, then check your reasoning. This is practice, not a scored test.

Should a triggered task also specify a polling SCHEDULE?

Try it yourself

Why must the logging-only trigger demo stay suspended?

Compare your reasoning

It never advances CONSUMER_B, so its work signal can remain true and cause unnecessary repeat executions.

Official sources and curriculum

Module 11 · See module scope