Module 08 · Lesson 12 of 12Detailed study · about 15 min

Lab: auto-ingest a file and design streaming recovery

Prove one file flow end to end, then walk through a streaming crash using explicit checkpoints.

Understand the idea

Complete setup and exactly one provider branch. For the SNS alternative substitute M8_SNS_PIPE wherever M8_AUTO_PIPE appears. Confirm the source prefix was initially empty and target table is fresh. Complete notifications before uploading batch001.json through the provider console/CLI; PUT does not upload into an external stage.

Key ideas in simple English
ConceptWhat it means
File labOne provider, one fresh prefix, one pipe.
Success evidenceArrival event, successful file history, two target rows.
Recovery drillSubmitted offsets 40–42; committed checkpoint 40.
Stop procedurePause ingestion and remove only dedicated lab resources.

A concrete example

batch001.json contributes events 801 and 802. A later malformed file should be diagnosed without replacing the pipe.

Remember: The file flow is hands-on; the streaming recovery section is a design exercise until you connect a supported client.

Explain it step by step · full theory

Setup and reasoning

Complete setup and exactly one provider branch. For the SNS alternative substitute M8_SNS_PIPE wherever M8_AUTO_PIPE appears. Confirm the source prefix was initially empty and target table is fresh. Complete notifications before uploading batch001.json through the provider console/CLI; PUT does not upload into an external stage.

Inspect COPY_HISTORY and target rows after asynchronous delivery. If absent, follow the diagnostics lesson. Upload a separate intentionally malformed bad001.json only to this lab prefix to inspect a failure and, if configured, outbound notification delivery. Do not overwrite batch001.json.

For the streaming drill, create the streaming pipe if authorized, then document source replay, channel ownership, committed checkpoint, rejected-row storage and restart behavior. Actual SDK execution is optional follow-on work; SQL creation alone does not test recovery.

After collecting evidence, stop the producer, pause the pipe and disable only the dedicated cloud notification rule. Then optionally remove the lab schema and dedicated integrations/resources after checking dependencies. Pausing a pipe alone does not stop cloud event accumulation.

Words used in this lesson
File lab
One provider, one fresh prefix, one pipe.
Success evidence
Arrival event, successful file history, two target rows.
Recovery drill
Submitted offsets 40–42; committed checkpoint 40.
Stop procedure
Pause ingestion and remove only dedicated lab resources.

See how it works

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

Open the interactive explanation
Interactive explainer1 / 3

Lab: auto-ingest a file and design streaming recovery

File lab
Success evidence

Identify the input

Prove one file flow end to end, then walk through a streaming crash using explicit checkpoints.

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. Identify the input

    Prove one file flow end to end, then walk through a streaming crash using explicit checkpoints.

  2. Follow delivery

    batch001.json contributes events 801 and 802. A later malformed file should be diagnosed without replacing the pipe.

  3. Verify and recover

    The file flow is hands-on; the streaming recovery section is a design exercise until you connect a supported client.

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 examples only. Complete Modules 05–07 and the first lesson’s M8_LAB setup. Select L2_OBJECTS_LAB.M8_LAB in each SQL session. Replace every placeholder and choose exactly one cloud provider. Cloud IAM/notifications require authorized setup; streaming protocol outlines are explicitly non-executable. No credentials belong in this website.

Save batch001.json and upload to the selected cloud prefix

JSON file contents · example
{"event_id":801,"message":"opened"}
{"event_id":802,"message":"closed"}

What to expect and why

Upload after notifications are configured. Each line is a separate JSON event.

Verify identity as well as count

SQL · example
SELECT PAYLOAD:event_id::NUMBER AS EVENT_ID,
 PAYLOAD:message::VARCHAR AS MESSAGE FROM M8_FILE_EVENTS ORDER BY EVENT_ID;
SELECT PAYLOAD:event_id::NUMBER AS EVENT_ID, COUNT(*) AS COPIES
 FROM M8_FILE_EVENTS GROUP BY 1 HAVING COUNT(*) <> 1;
SELECT SYSTEM$PIPE_STATUS('L2_OBJECTS_LAB.M8_LAB.M8_AUTO_PIPE');

What to expect and why

Expected good-file results: 801/opened and 802/closed; duplicate check returns no rows. Inspect COPY_HISTORY as well; expected values are not a latency guarantee.

Streaming drill and controlled shutdown

Manual exercise · example
1. Source partition p0 has offsets 40, 41, 42.
2. Stable channel p0 reports committed offset 40 after a crash.
3. Reopen p0, inspect errors, seek source to 41 and resume.
4. If offset 41 was rejected, retain its payload/reason durably.
5. Explain why a new random channel or acknowledging 42 early is unsafe.
6. Stop the lab producer and disable its dedicated cloud event route.

What to expect and why

Review the design against the Named Channel protocol. Include the ambiguous-request case; continuation tokens and source offsets are separate.

Pause after collecting evidence

SQL · example
ALTER PIPE M8_AUTO_PIPE SET PIPE_EXECUTION_PAUSED=TRUE;
-- Optional only after cloud notifications and clients are stopped:
-- DROP SCHEMA L2_OBJECTS_LAB.M8_LAB CASCADE;

What to expect and why

Do not drop shared storage integrations from Module 05. Clean up dedicated cloud resources through the authorized provider administrator.

Check your understanding

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

Which evidence proves the file lab’s expected outcome?

Try it yourself

Write the response to a crash after submission but before an acknowledged commit.

Compare your reasoning

Keep the source data, reopen the stable channel using the documented protocol, read committed progress and errors, then replay from the correct source position. Do not guess from the last submitted offset.

Official sources and curriculum

Module 08 · See module scope