Target lag and the dependency graph
A dependency graph records which result reads which source. The consumer-facing freshness target drives refreshes through upstream dependencies.
Understand the idea
The dashboard reads customer totals, so it is the leaf consumer. Its five-minute target describes the age we aim for relative to the pipeline’s base data, not an instruction to execute exactly every five minutes.
| Concept | What it means |
|---|---|
| Root source | RAW_ORDERS is the original input. |
| Intermediate | CLEAN_ORDERS uses DOWNSTREAM. |
| Leaf result | CUSTOMER_TOTALS has a time-based target. |
| Actual lag | Observed freshness can exceed the target. |
A concrete example
The dashboard reads customer totals, so it is the leaf consumer. Its five-minute target describes the age we aim for relative to the pipeline’s base data, not an instruction to execute exactly every five minutes.
Remember: Target lag is a best-effort freshness objective; monitor actual freshness and refresh duration.
Explain it step by step · full theory
Understand the concept
The dashboard reads customer totals, so it is the leaf consumer. Its five-minute target describes the age we aim for relative to the pipeline’s base data, not an instruction to execute exactly every five minutes.
Snowflake coordinates refreshes through the declared query dependencies. DOWNSTREAM on the clean layer lets the consumer’s needs drive its work. If every table had DOWNSTREAM and no timed consumer existed, there would be no automatic refresh driver.
Apply it to our pipeline
The minimum time-based target is one minute, but choosing the shortest possible value is not automatically useful. If refreshes take longer than the target, the pipeline can miss its freshness goal. Choose a business requirement, then measure it.
Manual refresh is useful for this ordered lab. Wait for a successful refresh and inspect history before interpreting outputs. Do not build a tight loop of manual refreshes as a replacement for normal scheduling.
Words used in this lesson
- Root source
- RAW_ORDERS is the original input.
- Intermediate
- CLEAN_ORDERS uses DOWNSTREAM.
- Leaf result
- CUSTOMER_TOTALS has a time-based target.
- Actual lag
- Observed freshness can exceed the target.
See how it works
Choose a step to explore the idea at your own pace.
Open the interactive explanation
Target lag and the dependency graph
Read the dependency
A dependency graph records which result reads which source. The consumer-facing freshness target drives refreshes through upstream dependencies.
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
- Read the dependency
A dependency graph records which result reads which source. The consumer-facing freshness target drives refreshes through upstream dependencies.
- Observe the result
After successful initialization: A / 2 / 150. There is no B row because B has no paid orders.
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.
- No account yet? Read and predict the output first. Follow the account and Snowsight lesson when you are ready.
- 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.
- 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. - 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.
Target lag and the dependency graph — manual SQL
Definition: A dependency graph records which result reads which source. The consumer-facing freshness target drives refreshes through upstream dependencies.
When to use: Practise in the isolated M12_LAB schema.
Example: After successful initialization: A / 2 / 150. There is no B row because B has no paid orders.
CREATE DYNAMIC TABLE CUSTOMER_TOTALS
TARGET_LAG='5 minutes'
WAREHOUSE=YOUR_LAB_WH
REFRESH_MODE=INCREMENTAL
INITIALIZE=ON_CREATE
AS SELECT CUSTOMER_ID,COUNT(*) AS ORDER_COUNT,SUM(AMOUNT) AS TOTAL_AMOUNT
FROM CLEAN_ORDERS GROUP BY CUSTOMER_ID;
SELECT * FROM CUSTOMER_TOTALS ORDER BY CUSTOMER_ID;
-- Optional explicit lab refresh of the dependency pipeline:
ALTER DYNAMIC TABLE CUSTOMER_TOTALS REFRESH;What to expect and why
After successful initialization: A / 2 / 150. There is no B row because B has no paid orders.
Check your understanding
Choose an answer, then check your reasoning. This is practice, not a scored test.
Try it yourself
Explain why: Does a five-minute target guarantee refresh starts exactly every five minutes?
Compare your reasoning
Target lag is a best-effort freshness objective; monitor actual freshness and refresh duration.