Object reference · Lesson 4 of 8Detailed study · about 12 min

Pipes, streams and tasks

A pipe defines a Snowpipe file load, a stream exposes row changes, and a task runs SQL work. They represent different stages of a data pipeline.

Understand the idea

A pipe is the loading definition, not the files or the destination data. Automatic file ingestion also needs event notification configuration. Creating a pipe without that setup does not mean every new cloud file will arrive automatically.

Key ideas in simple English
ConceptWhat it means
PipeStores the COPY statement used by Snowpipe for file ingestion.
StreamTracks a change offset and exposes changes since that point.
TaskRuns SQL on a schedule or trigger using configured compute.

A concrete example

New order files are ingested through a pipe. A stream exposes changes in the landing table. A task can apply those changes to a reporting table.

Remember: A stream does not run SQL for you, and a task does not automatically know which rows are new.

Explain it step by step · full theory

Understand the idea

A pipe is the loading definition, not the files or the destination data. Automatic file ingestion also needs event notification configuration. Creating a pipe without that setup does not mean every new cloud file will arrive automatically.

A stream acts like a bookmark in supported source change history. A plain SELECT can inspect the changes without advancing that bookmark. A committed DML operation that consumes the stream advances its offset. A stream must be consumed within its retention constraints to avoid staleness.

Follow the example

Tasks provide execution. They can run statements or call procedures, using a configured warehouse or supported serverless execution. Streams and tasks are often combined, but each is independently meaningful. A pipeline also needs ownership, privileges and failure monitoring.

The example creates a stream after the two sample orders already exist. It then inserts a third order. The stream starts at its creation point, so the new insert is visible while the earlier two rows are not new changes. Repeat SELECT to observe that reading alone does not consume it.

With the original setup and this insert run once, the stream shows order 103 with action INSERT. The source table now contains three orders totaling 125.00. No task or pipe is created by this example.

Words used in this lesson
Pipe
Stores the COPY statement used by Snowpipe for file ingestion.
Stream
Tracks a change offset and exposes changes since that point.
Task
Runs SQL on a schedule or trigger using configured compute.

See how it works

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

Open the interactive explanation
Interactive explainer1 / 3

Pipes, streams and tasks

Northstar sales team
Business requirement

Start with the requirement

New order files are ingested through a pipe. A stream exposes changes in the landing table. A task can apply those changes to a reporting table.

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. Start with the requirement

    New order files are ingested through a pipe. A stream exposes changes in the landing table. A task can apply those changes to a reporting table.

  2. Choose the objects

    Compare the responsibilities: Pipe: Stores the COPY statement used by Snowpipe for file ingestion.; Stream: Tracks a change offset and exposes changes since that point.; Task: Runs SQL on a schedule or trigger using configured compute.

  3. Explain the outcome

    A stream does not run SQL for you, and a task does not automatically know which rows are new.

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.
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

Examples are for reading first. Optional execution requires an authorized learning account, a selected warehouse for queries, and privileges on the named objects. Nothing runs on this website.

Read the example

SQL · example
CREATE STREAM L2_OBJECTS_LAB.SALES.ORDER_CHANGES ON TABLE L2_OBJECTS_LAB.SALES.ORDERS;
INSERT INTO L2_OBJECTS_LAB.SALES.ORDERS VALUES (103, 25.00);
SELECT ORDER_ID, METADATA$ACTION AS ACTION
FROM L2_OBJECTS_LAB.SALES.ORDER_CHANGES;

What to expect and why

With the original setup and this insert run once, the stream shows order 103 with action INSERT. The source table now contains three orders totaling 125.00. No task or pipe is created by this example.

Check your understanding

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

Does a plain SELECT consume a stream and move its offset?

Try it yourself

Assign the responsibilities: receive files, identify new table changes, run a transformation.

Compare your reasoning

A pipe defines Snowpipe loading, a stream exposes changes, and a task runs the transformation. Merely reading a stream leaves its offset in place; consumption requires the appropriate committed DML operation.

Official sources and curriculum

Object reference · See module scope