What you will be able to do
- Explain what a stream stores and exactly when its offset advances
- Choose between standard, append-only and insert-only streams
- Configure a task's compute, schedule and stream trigger, and chain tasks into a task graph
- Define a dynamic table with a target lag and refresh mode
1.Streams record an offset, not data
Loading tools land raw data, but they cannot join, aggregate or filter it on the way in. Continuous pipelines therefore transform the data after it has landed, and to do that efficiently they need to know which rows changed since the last run. A stream provides that change data capture (CDC). It records inserts (including COPY INTO), updates and deletes on a source object, so a pipeline can process just the changed rows.
A stream holds no table data itself. When created, it sets an offset, a point in the source object's transaction history, and when queried it returns the changes committed after that point, read from the object's versioning history. Think of it as a bookmark: you can drop it, or place more streams at the same or different points. The first stream on a table adds hidden change-tracking columns to that table, which use a small amount of storage. For a stream on a view, change tracking has to be enabled explicitly on the view and on its underlying tables. Streams can be created on standard tables (including shared tables), views, directory tables, dynamic tables, Iceberg tables, event tables and external tables.
| Column | Meaning |
|---|---|
| METADATA$ACTION | The DML operation recorded: INSERT or DELETE |
| METADATA$ISUPDATE | TRUE when the record is half of the DELETE/INSERT pair that represents an UPDATE |
| METADATA$ROW_ID | A unique, immutable ID for tracking a row over time |
A stream returns the minimal set of changes between its offset and now. If a row is inserted and then updated before the offset advances, the stream shows a single new row with METADATA$ISUPDATE = FALSE, not the update.
Checkpoint 1 of 6· Check yourself
A stream is created on table ORDERS. Before anything consumes the stream, a row is inserted into ORDERS and then updated. What does a query on the stream return for that row?
A stream returns the smallest set of changes between its offset and now. A row that was inserted and then updated after the offset therefore shows up as one new row with METADATA$ISUPDATE = FALSE. The stream keeps no copy of the row. It reads the row's current state from the table's version history.
“row is added and then updated in the current offset, the delta change is a new row. The METADATA$ISUPDATE row records a FALSE value.”Source: docs.snowflake.com
Sources1
2.When a stream's offset moves
Only consumption moves the offset. Any number of queries can read the same change records without affecting the stream. The offset advances when the stream is used in a DML transaction that commits, such as INSERT INTO target SELECT ... FROM my_stream, a CREATE TABLE AS SELECT or a COPY INTO location, and this holds for both autocommit and explicit transactions. If the transaction rolls back, the offset stays where it was. So when a stream still shows the same rows after a pipeline has run, check whether a DML statement that read the stream actually committed. SELECT statements, however many, do not count.
Inside an explicit transaction, a stream gives repeatable reads: every statement sees the changes from the offset up to the transaction's start time. Wrapping several DML statements in BEGIN ... COMMIT lets them all consume the same change set and locks the stream. Changes committed by other transactions in the meantime are tracked and appear after the commit.
Sometimes you want to skip the pending changes without processing them. There are two ways to move the offset to the current version: recreate the stream with CREATE OR REPLACE STREAM, or run an INSERT into a temporary table that selects from the stream with a filter that matches nothing, such as WHERE 0 = 1.
Checkpoint 2 of 6· Check yourself
A stream on RAW_EVENTS has built up a large backlog of change records that the team has decided to discard. They want the offset moved to the current table version without processing the backlog. Which action does that?
The offset moves only when a DML statement that reads the stream commits. An INSERT that selects from the stream with a filter matching no rows still commits, so it advances the offset without writing anything. A SELECT alone never moves the offset. A rolled-back transaction leaves the offset where it was. Deleting rows from the source creates more change records.
“In the INSERT statement, query the stream but include a WHERE clause that filters out all of the change data”Source: docs.snowflake.com
Sources1
3.Standard, append-only and insert-only streams
The stream type is chosen at creation with a parameter, and the choice is about which changes you need. A standard stream joins the deleted and inserted rows to work out what was updated and what was deleted. A pipeline that only ever sees new rows does not need that work, and paying for it is wasted effort.
| Type | How you create it | Records | Supported on |
|---|---|---|---|
| Standard | Default | Inserts, updates and deletes | Tables, views and the other supported objects |
| Append-only | APPEND_ONLY = TRUE | Row inserts only; updates, deletes and truncates are not recorded | Standard tables, or views that query standard tables |
| Insert-only | INSERT_ONLY = TRUE | Row inserts only | Required for external tables and externally managed Iceberg tables |
An append-only stream can perform much better than a standard stream in ELT flows that depend only on inserts. For example, you can truncate the source table as soon as the stream has been consumed, and those deletions add no overhead the next time the stream is read. For an external table over files that are only ever added, the insert-only stream is not merely a good choice; it is the only type allowed.
Checkpoint 3 of 6· Check yourself
To cut compute, an engineer proposes switching the stream on CUSTOMERS to APPEND_ONLY = TRUE. A MERGE job reads that stream to keep a reporting table in sync, and customer records in CUSTOMERS are regularly updated and deleted. What should the team do?
The standard stream is the default type, and it is the one that records inserts, updates and deletes. An append-only stream records only row inserts, so its METADATA$ISUPDATE never flags an update and the MERGE never sees deletes. Append-only streams save work only when a flow depends on inserts alone.
“A stream object records data manipulation language (DML) changes made to tables, including inserts (including COPY INTO), updates, and deletes”Source: docs.snowflake.com
Sources2
4.Tasks: schedules, triggers and compute
A task runs a SQL statement or stored procedure automatically, either on a schedule or when a stream has new data. A new task starts out suspended. EXECUTE TASK runs it once for testing, and ALTER TASK ... RESUME lets it follow its schedule or watch for events.
Compute comes in two models. A serverless task omits the WAREHOUSE parameter. Snowflake sizes each run from an analysis of recent runs, up to a maximum equivalent to an XXLARGE warehouse, and you can bound it with SERVERLESS_TASK_MIN_STATEMENT_SIZE and SERVERLESS_TASK_MAX_STATEMENT_SIZE. The role that runs a serverless task needs the global EXECUTE MANAGED TASK privilege. A user-managed task names a WAREHOUSE and gives you full control over compute; it is the only option when a workload needs more than XXLARGE.
| Factor | Serverless tasks | User-managed tasks |
|---|---|---|
| Workload shape | Under-utilized warehouses, quick or stable runs | Fully utilized warehouses with many concurrent tasks; unpredictable loads on compute |
| Schedule adherence | Recommended when keeping to the interval matters; compute grows if a run overruns | Recommended when keeping to the interval matters less |
| Billing | Actual compute resource usage | Warehouse size, with a 60-second minimum each time it resumes |
A schedule is either an interval, such as SCHEDULE='10 SECONDS', or a cron expression with a time zone (SCHEDULE='USING CRON 7 3 * * SUN America/Los_Angeles'). Only one instance of a scheduled task runs at a time; if a run is still going when the next one is due, that scheduled time is skipped.
Pairing a task with a stream turns it into a pipeline step. When the stream has no change data, a WHEN SYSTEM$STREAM_HAS_DATA condition skips the run. A task on a fixed schedule that usually finds nothing to do can add that condition so that empty runs consume no compute. Without a schedule, the task becomes a triggered task that runs as soon as the stream has data. A serverless triggered task also needs a target completion interval.
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;Checkpoint 4 of 6· Fill the gap
This task should run only when orders_stream has new change data, and it has no SCHEDULE. Which keyword completes the definition?
CREATE TASK triggered_task_stream
? SYSTEM$STREAM_HAS_DATA('orders_stream')
AS
INSERT INTO completed_promotions
SELECT order_id, order_total, order_time, promotion_id
FROM orders_stream;The WHEN clause holds the SYSTEM$STREAM_HAS_DATA condition. Because the task has no schedule, it becomes a triggered task that runs as soon as the stream has data. WHERE filters rows inside a query, and SCHEDULE takes an interval or a cron expression, not a stream condition.
Source: docs.snowflake.comSources3
5.Task graphs chain tasks from a root
A task graph links tasks by dependency, so that a multi-step pipeline runs in order and steps without dependencies on each other can run in parallel. The root task carries the schedule. Every child task names one or more predecessors with the AFTER parameter, and a child runs only once all of its predecessors have finished successfully. Picture a root task that loads raw data, a cleansing task created AFTER the root, and two reporting tasks each created AFTER the cleansing task. The reports never start unless cleansing succeeds.
A task graph has several structural rules:
- A single task can have at most 100 predecessors and 100 children, and a graph can hold at most 1000 tasks including the root.
- All tasks in the graph must have the same owner role and live in the same schema.
- The root task must be suspended before any task in the graph is recreated, or before a child is added with CREATE TASK ... AFTER or ALTER TASK ... ADD AFTER, or removed with ALTER TASK ... REMOVE AFTER.
ALTER TASK ... ADD AFTER, run against each child to name its predecessors. The root task must be suspended while you do it.
Checkpoint 5 of 6· Check yourself
An engineer is building a pipeline as a task graph. LOAD_RAW lands the data, CLEANSE tidies it, and two reporting tasks should run side by side, but only on cleansed data. How should the schedule and dependencies be set up?
In a task graph, only the root task carries the schedule. Each child names its predecessors with AFTER and runs only after all of them have finished successfully. Making both reports AFTER CLEANSE means they run in parallel with each other and never run on uncleansed data. Making them AFTER LOAD_RAW would let them start before cleansing has finished.
“Schedule interval refers to the interval of time between scheduled runs of a standalone task or the root task in a task graph.”Source: docs.snowflake.com
Sources4
6.Dynamic tables: declare the result, set a target lag
A dynamic table replaces the stream, task and DML you would otherwise write with a single declaration. You write the SELECT that defines the result and set a target lag. Snowflake then identifies the base tables, watches them for changes and refreshes the table so that it stays within that lag. Each refresh is applied atomically, so readers never see a partial result.
CREATE OR ALTER DYNAMIC TABLE dt_orders
TARGET_LAG = '10 minutes'
WAREHOUSE = transform_wh
REFRESH_MODE = INCREMENTAL
AS
SELECT
order_id,
customer_id,
order_date,
TRIM(UPPER(product_name)) AS product_name,
quantity,
unit_price,
quantity * unit_price AS line_total,
order_status
FROM raw_orders
WHERE order_status != 'returned';Target lag is a goal, not a guarantee. A 10-minute lag means Snowflake tries to keep the data no more than 10 minutes behind the base tables, but a slow refresh can push the actual lag past that. An intermediate table can set TARGET_LAG = DOWNSTREAM, which makes it refresh only when the tables that depend on it need fresh data.
| REFRESH_MODE | Behaviour |
|---|---|
| INCREMENTAL | Processes only the rows that changed since the last refresh |
| FULL | Recomputes the entire result set |
| AUTO | Snowflake picks at creation time, based on whether the query supports incremental refresh |
| ADAPTIVE | Incremental by default, reinitializing when large upstream changes are detected |
| CUSTOM_INCREMENTAL | You define the refresh logic yourself with DML statements |
Chaining dynamic tables builds a pipeline with no task graph to maintain. When dt_orders_daily reads from dt_orders and joins dim_customers, Snowflake infers the dependency graph from the queries and refreshes the tables in dependency order. Each refresh uses a consistent snapshot, so downstream tables always see coherent inputs. The difference from streams and tasks is who writes the plumbing. With streams and tasks you write the consuming DML, the schedule and the AFTER links yourself. With dynamic tables you declare the result and Snowflake handles scheduling and incremental processing. If an external orchestrator such as dbt or Airflow should drive refreshes instead, set SCHEDULER = DISABLE.
Checkpoint 6 of 6· Match them up
A team is deciding how each dynamic table in its pipeline should refresh. Match each REFRESH_MODE value to the behaviour it gives.
Tap a term, then the definition that fits it.
INCREMENTAL and FULL are fixed choices between processing only the changed rows and recomputing everything. AUTO decides once, at creation, from the query. ADAPTIVE refreshes incrementally but reinitializes when large upstream changes are detected.
“ADAPTIVE uses incremental refresh by default but automatically reinitializes when large upstream changes are detected.”Source: docs.snowflake.com
Sources5
Sources
(5)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“A stream only stores an offset for the source object and returns CDC records by leveraging the versioning history for the source object.”
↩︎ Streams record an offset, not data“Updates to rows in the source object are represented as a pair of DELETE and INSERT records in the stream”
↩︎ Streams record an offset, not data“Querying a stream alone does not advance its offset, even within an explicit transaction; the stream contents must be consumed in a DML statement.”
↩︎ When a stream's offset moves“A stream advances the offset only when it is used in a DML transaction.”
↩︎ Exam trap 1“row is added and then updated in the current offset, the delta change is a new row. The METADATA$ISUPDATE row records a FALSE value.”
↩︎ Checkpoint“In the INSERT statement, query the stream but include a WHERE clause that filters out all of the change data”
↩︎ Checkpoint“A stream object records data manipulation language (DML) changes made to tables, including inserts (including COPY INTO), updates, and deletes”
↩︎ Checkpoint - 2.
“Append-only streams track row inserts only. Update and delete operations (including table truncates) are not recorded.”
↩︎ Standard, append-only and insert-only streams“Required for streams on external tables and externally managed Iceberg tables.”
↩︎ Standard, append-only and insert-only streams - 3.https://docs.snowflake.com/en/user-guide/tasks-introOfficial docs
“The maximum compute size for a serverless task is equivalent to an XXLARGE virtual warehouse.”
↩︎ Tasks: schedules, triggers and compute“Snowflake ensures only one instance of a task with a schedule is run at a time.”
↩︎ Tasks: schedules, triggers and compute“When a task is created, it starts as suspended.”
↩︎ Exam trap 2“Schedule interval refers to the interval of time between scheduled runs of a standalone task or the root task in a task graph.”
↩︎ Checkpoint - 4.
“A task graph is a series of tasks that starts with a scheduled root task and is linked together by dependencies.”
↩︎ Task graphs chain tasks from a root“A task runs after all of its predecessor tasks have finished their own runs successfully (after a brief lag).”
↩︎ Task graphs chain tasks from a root - 5.
“You specify a SELECT query and a target lag, and Snowflake tracks dependencies and refreshes the data on schedule.”
↩︎ Dynamic tables: declare the result, set a target lag“actual lag can exceed the target when refreshes take longer than expected”
↩︎ Dynamic tables: declare the result, set a target lag“actual lag can exceed the target when refreshes take longer than expected”
↩︎ Exam trap 3“ADAPTIVE uses incremental refresh by default but automatically reinitializes when large upstream changes are detected.”
↩︎ Checkpoint