Module 20 · Lesson 4 of 11Detailed study · about 36 min

Snowflake Pipeline Monitoring: COPY, Snowpipe, Streaming, Tasks and Dynamic Tables

Trace a delivery from the source to the published table, reconcile row counts and diagnose failures with the history for each pipeline component.

Before you beginKnow where to find load and task history

Follow the same batch from source to target

Extract, transform, load (ETL) changes the data before writing it to the destination. Extract, load, transform (ELT) puts raw data in the destination first and changes it there. In either case, measure what arrived, what was rejected and what reached the final table. The sales example uses ELT.

A load can be successful and still leave a report incomplete. The load may have accepted every file it received while a second expected file never arrived. Or it may have loaded two rows into a raw table, but a business check rejected one during transformation.

Make an expected batch record with a delivery deadline, an expected count or manifest, and a source cutoff. A manifest is a list of inputs you expect. Each attempt records start, finish, status, source count, target count, totals and a safe error summary. Count source and target for the same batch and explain legitimate differences from filtering, grouping or deduplication. Record source-event time separately from arrival and publish times.

Representative audit outcomes after the capstone’s retry
BatchAttemptSource rowsMatched target rowsStatus
B101122PUBLISHED
B102120REJECTED
B102222PUBLISHED
Operational evidence travels with the batch Source and target evidence meet at publication. A failed attempt leaves a record that the retry can refer to.
  1. Expected sourceCompare arrival to Load history
  2. Load historyProcess loaded rows to Validation and transformation
  3. Validation and transformationCheck and record to Attempt audit
Expected source
Due time, file list and source cutoff.
Load history
Files seen, rows parsed and written, and errors.
Validation and transformation
Measure accepted rows and check business rules.
Attempt audit
Record verified counts, totals, status and error.

Check bulk COPY and file-based Snowpipe

COPY INTO loads files you select from a stage. File-based Snowpipe loads eligible files from a pipe that contains a COPY definition, commonly after a cloud notification. Look up the exact expected file name in recent COPY_HISTORY. Compare ROW_PARSED, ROW_COUNT, STATUS and FIRST_ERROR_MESSAGE. A missing row can mean a missing notification, a filter mismatch, no completed load in range or a visibility issue. Check upstream object storage or LIST on the stage with an approved role.

For a pipe, use its owner or a role with MONITOR on the pipe. Parse SYSTEM$PIPE_STATUS as semi-structured data so you can read its named fields. RUNNING means the pipe is operational. It does not show that a particular file was processed. With no pending files, fields for the oldest queued file can be absent. Compare the notification and file timestamps with recent copy history before changing the pipe.

Representative outcomes with a pre-existing file and pipe
EvidenceExampleInterpretation
COPY_HISTORYsales_b102.csv · Partially loaded · 2 parsed · 1 writtenInspect the first parsing error. Reconcile source totals before replaying.
Pipe statusRUNNING · 2 pending · last notice 07:48 UTCNotifications reached the pipe. Inspect the oldest pending file and compare later history.
SQL · configuration template
SELECT file_name, status, row_parsed, row_count, first_error_message
FROM TABLE(LS_M20_OPS_LAB.INFORMATION_SCHEMA.COPY_HISTORY(
  TABLE_NAME => 'LS_M20_OPS_LAB.OPS.SOURCE_ORDERS',
  START_TIME => DATEADD('hour', -6, CURRENT_TIMESTAMP())
))
ORDER BY last_load_time DESC;

WITH pipe_status AS (
  SELECT PARSE_JSON(SYSTEM$PIPE_STATUS('LS_M20_OPS_LAB.OPS.SALES_PIPE')) AS status
)
SELECT status:"executionState"::STRING AS execution_state,
       status:"pendingFileCount"::NUMBER AS queued_files,
       status:"lastReceivedMessageTimestamp"::STRING AS last_notice
FROM pipe_status;

Watch Snowpipe Streaming in the right place

Snowpipe Streaming sends rows through a channel. It does not require intermediate files for each batch. For high-performance architecture with named channels, check producer send and commit outcomes, latest committed offset, the event table if enabled, and the channel error history below. This view records channels that encountered ingestion errors. For successful ingestion and latency, read the high-performance SDK channel status and reconcile the target. For classic architecture, use the classic APIs to monitor and read committed offsets. Do not apply the high-performance channel view to classic traffic.

A producer can report it accepted a batch for sending before all rows are visible. Correlate application offsets or record IDs with committed progress and target rows. Log the channel and batch ID, and reconcile records rejected by supported error handling. Offset tokens are application-defined progress markers, so a larger-looking token alone is not proof that all records were processed.

Representative producer check and resulting action
Producer sentLatest committedTarget evidence
offset 103offset 101Only orders through 101 are verified. Check producer errors and commits before resending.
SQL · configuration template
SELECT created_on, pipe_name, channel_name, rows_parsed, rows_inserted,
       row_error_count, last_error_message
FROM SNOWFLAKE.ACCOUNT_USAGE.SNOWPIPE_STREAMING_CHANNEL_HISTORY
ORDER BY created_on DESC LIMIT 20;

Check Streams, Tasks and Dynamic Tables independently

A stream points to a place in the source’s change history. Read STALE and STALE_AFTER with SHOW STREAMS. A committed transaction that consumes the stream in data-changing SQL can advance the offset. A plain SELECT does not. SYSTEM$STREAM_HAS_DATA can be true when the actual stream query has no rows. Pair it with an audit of what changed and what was published.

A task runs SQL on a schedule, after a trigger or after prerequisites. Check state and query ID, then inspect permissions, error text, task dependencies and compute. If a task calls a procedure that returns REJECTED normally, the engine may report SUCCEEDED. Your batch audit still shows rejection.

A dynamic table stores a query result and refreshes it to try to meet a target lag. Read this function as a role with MONITOR on the dynamic table or a privilege that includes it. Compare its DATA_TIMESTAMP with the desired freshness and inspect STATE and STATE_MESSAGE. A healthy refresh may produce no new report if the upstream source has no new data. For a failure in a chain, start at the earliest failed upstream refresh and inspect the downstream dependency before resuming.

What a short status scan could show
ComponentExample observationNext step
StreamSTALE = false · STALE_AFTER tomorrowCheck the consumer’s last committed run and data contract.
TaskSUCCEEDED · q-maple-20Find the matching attempt and verify PUBLISHED.
Dynamic tableFAILED · state message shows permission issueIdentify the failing dependency and restore the correct owner role’s access.
SQL · configuration template
SHOW STREAMS IN SCHEMA LS_M20_OPS_LAB.OPS;

SELECT name, scheduled_time, state, query_id, error_message
FROM TABLE(LS_M20_OPS_LAB.INFORMATION_SCHEMA.TASK_HISTORY(
  SCHEDULED_TIME_RANGE_START => DATEADD('hour', -2, CURRENT_TIMESTAMP()),
  TASK_NAME => 'SALES_TASK'
))
WHERE database_name = 'LS_M20_OPS_LAB' AND schema_name = 'OPS'
ORDER BY scheduled_time DESC;

SELECT name, state, data_timestamp, refresh_start_time, state_message
FROM TABLE(LS_M20_OPS_LAB.INFORMATION_SCHEMA.DYNAMIC_TABLE_REFRESH_HISTORY(
  NAME => 'LS_M20_OPS_LAB.OPS.SALES_DAILY_DT', RESULT_LIMIT => 20
))
ORDER BY refresh_start_time DESC;

Interview practice

Explain the decision and the evidence you would use to test it.

Beginner · Why can a loaded file produce a stale report?

The file may be incomplete, or it may have loaded successfully into raw storage while transformation or validation stopped further down the pipeline.

SQL · How would you detect delayed Snowpipe ingestion?

I look for the expected file and compare its arrival, pipe status and COPY_HISTORY. If it is missing from history, I check authorization, notifications and the load time window first.

Production · How do you retry safely after a partial load?

I confirm what was actually committed and reconcile source and target keys. I rerun an idempotent write scoped to the same batch, record the new attempt and only mark published after verifying the target.

Words used in this lesson
Batch ID
A key for one logical delivery. Separate attempts have their own attempt numbers.
Reconciliation
Checking that source and target records agree according to the same rules.
Stream staleness
A stream lost access to the history needed to read its changes.
Channel offset
A progress value the producer associates with committed streaming data so it can decide where to resume.

Try the SQL or command

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

Use the SQL and expected outputs in the sections above.

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

Maple Market is fictional. Output tables are representative. Live commands require an authorized test account and the roles, compute and edition listed in each lesson.

Check your understanding

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

Which record confirms all expected business rows were published?

Try it yourself

A stream has no available changes and a target is stale. What do you check before touching its offset?

Compare your reasoning

Check the expected source change and time, the task that consumes the stream, the stream’s STALE and STALE_AFTER, and the last committed audit. Reconcile against the source and plan a rebuild or replay if the offset is no longer usable.

Connect this lesson to the learning path

Official sources and curriculum

Module 20 · See module scope

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