By Rohit Ray · Independent educational lesson · Explore this visual lab

Module 12 · Lesson 7 of 9Detailed study · about 20 min

Bridge an incremental dynamic table into CDC

A standard stream on a supported incremental dynamic table captures changes in its refreshed output. It does not observe every intermediate source edit.

Understand the idea

Create the stream after the previous lessons. The current two clean rows are the baseline, so the new stream starts empty. It will observe output changes produced by later successful refreshes.

Key ideas in simple English
ConceptWhat it means
ON DYNAMIC TABLEThe correct stream source syntax.
Standard streamTracks net inserts, deletes and update pairs.
SELECTInspects changes without consuming them.
Committed DMLAdvances the consuming stream offset.

A concrete example

Create the stream after the previous lessons. The current two clean rows are the baseline, so the new stream starts empty. It will observe output changes produced by later successful refreshes.

Remember: Only the appropriate committed consuming transaction advances the stream offset; SELECT is inspection.

Explain it step by step · full theory

Understand the concept

Create the stream after the previous lessons. The current two clean rows are the baseline, so the new stream starts empty. It will observe output changes produced by later successful refreshes.

Only supported incremental dynamic tables can be used here; full-refresh sources do not support streams. Append-only streams are not supported on dynamic tables. Inspect the resolved mode before using an AUTO-defined table as a source.

Apply it to our pipeline

Now change A from 120 to 130. After refreshing the pipeline, the stream represents an update through a DELETE old row and INSERT new row with ISUPDATE true. Row order is not guaranteed.

Consume all change rows into a small audit table in one committed transaction. As in Module 11, a SELECT does not acknowledge work. Multiple independent consumers need independent streams, and retention/staleness still require monitoring. Replacing the source can disrupt downstream tracking; plan recovery before changing definitions.

Words used in this lesson
ON DYNAMIC TABLE
The correct stream source syntax.
Standard stream
Tracks net inserts, deletes and update pairs.
SELECT
Inspects changes without consuming them.
Committed DML
Advances the consuming stream offset.

See how it works

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

Open the interactive explanation
Interactive explainer1 / 2

Bridge an incremental dynamic table into CDC

RAW_ORDERS
CLEAN_ORDERS
CUSTOMER_TOTALS

Read the dependency

A standard stream on a supported incremental dynamic table captures changes in its refreshed output. It does not observe every intermediate source edit.

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. Read the dependency

    A standard stream on a supported incremental dynamic table captures changes in its refreshed output. It does not observe every intermediate source edit.

  2. Observe the result

    Initial pending 0. After refresh, expect the update pair for order 101: old 120 and new 130. After committed consumption, pending 0. Customer totals are A/1/130 and B/1/40.

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 Snowflake practice only. This website does not run SQL or provision compute. Refreshing dynamic tables uses billable resources.

Bridge an incremental dynamic table into CDC — manual SQL

Definition: A standard stream on a supported incremental dynamic table captures changes in its refreshed output. It does not observe every intermediate source edit.

When to use: Practise in the isolated M12_LAB schema.

Example: Initial pending 0. After refresh, expect the update pair for order 101: old 120 and new 130. After committed consumption, pending 0. Customer totals are A/1/130 and B/1/40.

SQL · example
CREATE STREAM CLEAN_CHANGES ON DYNAMIC TABLE CLEAN_ORDERS;
SELECT COUNT(*) AS INITIAL_PENDING FROM CLEAN_CHANGES;
CREATE TABLE CLEAN_CHANGE_AUDIT (
 ORDER_ID NUMBER,CUSTOMER_ID VARCHAR,AMOUNT NUMBER(12,2),ACTION VARCHAR,IS_UPDATE BOOLEAN
);
UPDATE RAW_ORDERS SET AMOUNT=130 WHERE ORDER_ID=101;
ALTER DYNAMIC TABLE CUSTOMER_TOTALS REFRESH;
SELECT ORDER_ID,AMOUNT,METADATA$ACTION,METADATA$ISUPDATE FROM CLEAN_CHANGES;
BEGIN TRANSACTION;
INSERT INTO CLEAN_CHANGE_AUDIT
 SELECT ORDER_ID,CUSTOMER_ID,AMOUNT,METADATA$ACTION,METADATA$ISUPDATE FROM CLEAN_CHANGES;
COMMIT;
SELECT COUNT(*) AS PENDING_AFTER_COMMIT FROM CLEAN_CHANGES;

What to expect and why

Initial pending 0. After refresh, expect the update pair for order 101: old 120 and new 130. After committed consumption, pending 0. Customer totals are A/1/130 and B/1/40.

Check your understanding

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

Does reading a stream with SELECT consume its pending changes?

Try it yourself

Explain why: Does reading a stream with SELECT consume its pending changes?

Compare your reasoning

Only the appropriate committed consuming transaction advances the stream offset; SELECT is inspection.

Official sources and curriculum

Module 12 · See module scope