In this post we are going to cover Snowpipe in Snowflake.
A pipe is a COPY INTO statement that Snowflake keeps for you and runs on its own schedule. You do not run the load. You put a file where the pipe is looking, and the pipe loads it.
A straight answer before we start. Half of Snowpipe needs cloud storage — S3, Azure or Google — and a notification integration to go with it. This was run on a trial account with no external stage, so that half is not reachable here and we are not going to pretend otherwise. We will do the half that is real and say clearly which half is which.
We will start with a stage and a table and build it up step by step. Every query below was run on a real Snowflake account, and every result you see is the output it gave back.
Episode 131 of the Snowflake SQL: Zero to Hero series on TechBrothersIT.
- Let's create some sample data
- Let's create a pipe
- Now let's ask the catalog the same question
- Now let's see what the pipe is actually holding
- What does a brand new pipe think of itself?
- Can we ask for AUTO_INGEST on an internal stage?
- Now let's put a file where the pipe is watching
- Let's tell the pipe to look
- So let's wait, and ask again
- Twelve rows from a six row file
- Can a pipe be paused?
- And what it refuses
- One last thing: the teardown
Let's create some sample data
A pipe needs somewhere to read from and somewhere to write to. So we need a stage, a file format, and an empty table for the rows to land in.
We also need a file. This post writes nothing from a laptop, so we build a second table and unload it to the stage when we are ready.
-- Sample data for this post.
-- A stage, a CSV format, a landing table, and a table to make a file from.
USE DATABASE DEMO_DB;
USE SCHEMA PUBLIC;
CREATE OR REPLACE STAGE STAGE_T131;
CREATE OR REPLACE FILE FORMAT CSV_T131
TYPE = CSV
FIELD_OPTIONALLY_ENCLOSED_BY = '"'
COMPRESSION = NONE;
CREATE OR REPLACE TABLE LANDING_T131 (
SALE_ID INT,
REGION VARCHAR(10),
AMOUNT NUMBER(10,2)
);
CREATE OR REPLACE TABLE SOURCE_T131 (
SALE_ID INT,
REGION VARCHAR(10),
AMOUNT NUMBER(10,2)
);
INSERT INTO SOURCE_T131 (SALE_ID, REGION, AMOUNT)
VALUES (1, 'north', 100.00), (2, 'north', 250.50),
(3, 'south', 75.25), (4, 'south', 310.00),
(5, 'east', 45.00), (6, 'east', 88.25);Let's note down what the source table holds, so we have something to check the load against later.
SELECT COUNT(*) AS ROWS_IN_THE_SOURCE,
SUM(AMOUNT) AS TOTAL_IN_THE_SOURCE
FROM SOURCE_T131;| ROWS_IN_THE_SOURCE | TOTAL_IN_THE_SOURCE |
|---|---|
| 6 | 869.00 |
Six rows, adding up to 869.00. Remember that total.
SELECT COUNT(*) AS ROWS_IN_THE_LANDING_TABLE FROM LANDING_T131;| ROWS_IN_THE_LANDING_TABLE |
|---|
| 0 |
Empty, which is where we want to start.
Let's create a pipe
CREATE PIPE, a name, the word AS, and then a COPY INTO statement. That is the whole object.
CREATE OR REPLACE PIPE PIPE_T131 AS
COPY INTO LANDING_T131
FROM @STAGE_T131/in/
FILE_FORMAT = (FORMAT_NAME = 'CSV_T131');| status |
|---|
| Pipe PIPE_T131 successfully created. |
Created. Now let's ask Snowflake what it thinks it has.
SHOW PIPES LIKE '%\\_T131' IN SCHEMA PUBLIC;| created_on | name | database_name | schema_name | definition | owner | notification_channel | comment | integration | pattern | error_integration | owner_role_type | invalid_reason | kind | is_snowflake_managed |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2026-10-01 13:18:14.529000-07:00 | PIPE_T131 | DEMO_DB | PUBLIC | COPY INTO LANDING_T131 FROM @STAGE_T131/in/ FILE_FORMAT = (FORMAT_NAME = 'CSV_T131') | ACCOUNTADMIN | NULL | NULL | NULL | NULL | ROLE | NULL | STAGE | false |
Fifteen columns, which is more than we need. Two things in there matter right now. The definition column is our COPY INTO, and the integration column is NULL. There is nothing for this pipe to listen to.
Have a look at the comment column in that grid as well. It is not NULL, it is an empty string, and the grid marks it as empty rather than printing a word into the cell. An absent comment and a comment set to nothing are two different things, and this is where you can see the difference.
A stage listing or a SHOW result is easier to read when we pull the columns we want out of it.
SELECT "name" AS THE_NAME,
"database_name" AS THE_DATABASE,
"integration" AS THE_INTEGRATION,
"pattern" AS THE_PATTERN,
"owner" AS THE_OWNER
FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()))
ORDER BY THE_NAME;| THE_NAME | THE_DATABASE | THE_INTEGRATION | THE_PATTERN | THE_OWNER |
|---|---|---|---|---|
| PIPE_T131 | DEMO_DB | NULL | NULL | ACCOUNTADMIN |
Name, database, integration, pattern, owner. Both the integration and the pattern are NULL.
Now let's ask the catalog the same question
INFORMATION_SCHEMA.PIPES answers this more plainly than SHOW PIPES does.
SELECT PIPE_NAME AS THE_NAME,
IS_AUTOINGEST_ENABLED AS IS_AUTO_INGEST,
NOTIFICATION_CHANNEL_NAME AS THE_CHANNEL,
PIPE_SCHEMA AS THE_SCHEMA
FROM INFORMATION_SCHEMA.PIPES
WHERE RIGHT(PIPE_NAME, 5) = '_T131';| THE_NAME | IS_AUTO_INGEST | THE_CHANNEL | THE_SCHEMA |
|---|---|---|---|
| PIPE_T131 | NO | NULL | PUBLIC |
Is auto ingest enabled: NO. Notification channel: NULL.
That is the same fact we just read off the SHOW output, written differently. SHOW PIPES reports the absence as a NULL integration. The view reports it as the word NO and a NULL channel. The two grids are not disagreeing with each other.
Now let's see what the pipe is actually holding
This is the one we wanted to look at. DESCRIBE PIPE.
DESCRIBE PIPE PIPE_T131;| created_on | name | database_name | schema_name | definition | owner | notification_channel | comment | integration | pattern | error_integration | owner_role_type | invalid_reason | kind | is_snowflake_managed |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2026-10-01 13:18:14.529000-07:00 | PIPE_T131 | DEMO_DB | PUBLIC | COPY INTO LANDING_T131 FROM @STAGE_T131/in/ FILE_FORMAT = (FORMAT_NAME = 'CSV_T131') | ACCOUNTADMIN | NULL | NULL | NULL | NULL | ROLE | NULL | STAGE | false |
Let's pull the definition out of that on its own.
SELECT "name" AS THE_NAME,
"definition" AS THE_COPY_STATEMENT
FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()));| THE_NAME | THE_COPY_STATEMENT |
|---|---|
| PIPE_T131 | COPY INTO LANDING_T131 FROM @STAGE_T131/in/ FILE_FORMAT = (FORMAT_NAME = 'CSV_T131') |
There is our statement, handed back word for word. COPY INTO LANDING_T131, from the stage and prefix, with the file format we named.
So a pipe is not a service you configure. It is a statement Snowflake is holding for you.
What does a brand new pipe think of itself?
There is a function for that, and it hands back a JSON string.
SELECT SYSTEM$PIPE_STATUS('PIPE_T131') AS THE_STATUS;| THE_STATUS |
|---|
| {"executionState":"RUNNING","pendingFileCount":0,"pendingHistoryRefreshJobsCount":0} |
Three keys: the execution state, a pending file count, and a count of pending history refresh jobs. The state is RUNNING and there is nothing pending.
That is easier to read as columns, so let's parse it.
SELECT PARSE_JSON(SYSTEM$PIPE_STATUS('PIPE_T131')):executionState::VARCHAR
AS EXECUTION_STATE,
PARSE_JSON(SYSTEM$PIPE_STATUS('PIPE_T131')):pendingFileCount::INT
AS PENDING_FILES,
PARSE_JSON(SYSTEM$PIPE_STATUS('PIPE_T131')):numOutstandingMessagesOnChannel::INT
AS OUTSTANDING_MESSAGES;| EXECUTION_STATE | PENDING_FILES | OUTSTANDING_MESSAGES |
|---|---|---|
| RUNNING | 0 | NULL |
Running, zero pending files, and outstanding messages NULL.
That last NULL is worth being careful about. We asked for numOutstandingMessagesOnChannel, and you can see from the JSON in the grid above that the status does not have a key by that name at all. Asking a VARIANT for a key it does not hold gives you NULL. So that cell is telling us the key is missing, not that a channel reported nothing.
Can we ask for AUTO_INGEST on an internal stage?
Auto ingest is the half that needs cloud storage and a notification integration. We have neither. So this one ought to be refused.
CREATE OR REPLACE PIPE AUTOPIPE_T131
AUTO_INGEST = TRUE AS
COPY INTO LANDING_T131
FROM @STAGE_T131/in/
FILE_FORMAT = (FORMAT_NAME = 'CSV_T131');| status |
|---|
| Pipe AUTOPIPE_T131 successfully created. |
Created. Not refused, not warned about. AUTO_INGEST = TRUE on an internal stage is simply accepted, and the pipe sits there with nothing to listen to.
Remember this second pipe. We made it to see whether the option would be refused, we left it pointed at the same prefix and the same table as the first one, and it is going to matter a great deal in a few sections' time.
Now let's put a file where the pipe is watching
Let's unload the source table into the prefix the first pipe reads from.
COPY INTO @STAGE_T131/in/sales.csv FROM SOURCE_T131
FILE_FORMAT = (FORMAT_NAME = 'CSV_T131')
SINGLE = TRUE;| rows_unloaded | input_bytes | output_bytes |
|---|---|---|
| 6 | 97 | 97 |
LIST @STAGE_T131/in/;| name | size | md5 | last_modified |
|---|---|---|---|
| stage_t131/in/sales.csv | 112 | ea0270064cfc01a17d9a3ae5d6addf26 | Thu, 1 Oct 2026 20:18:25 GMT |
One file, sitting exactly where the pipe is pointed.
On an external stage, that arrival would send a notification and the pipe would hear it. On an internal stage it sends nothing. So has anything loaded?
SELECT COUNT(*) AS ROWS_IN_THE_LANDING_TABLE FROM LANDING_T131;| ROWS_IN_THE_LANDING_TABLE |
|---|
| 0 |
Zero rows. The file is there and the table is empty.
SELECT PARSE_JSON(SYSTEM$PIPE_STATUS('PIPE_T131')):executionState::VARCHAR
AS EXECUTION_STATE,
PARSE_JSON(SYSTEM$PIPE_STATUS('PIPE_T131')):pendingFileCount::INT
AS PENDING_FILES;| EXECUTION_STATE | PENDING_FILES |
|---|---|
| RUNNING | 0 |
Running, nothing pending. It does not know the file exists.
Let's tell the pipe to look
ALTER PIPE ... REFRESH is the manual version of the notification that cannot arrive here. Have a look at the grid it gives back.
ALTER PIPE PIPE_T131 REFRESH;| File | Status |
|---|---|
| sales.csv | SENT |
Two columns, File and Status, and the status is SENT.
SENT, not LOADED. The file has been handed to the ingest service. That is all this statement promises.
SELECT PARSE_JSON(SYSTEM$PIPE_STATUS('PIPE_T131')):executionState::VARCHAR
AS EXECUTION_STATE,
PARSE_JSON(SYSTEM$PIPE_STATUS('PIPE_T131')):pendingFileCount::INT
AS PENDING_FILES;| EXECUTION_STATE | PENDING_FILES |
|---|---|
| RUNNING | 0 |
Still running, still nothing pending. The status JSON does not show us the queue here, which is not very helpful.
SELECT COUNT(*) AS ROWS_IN_THE_LANDING_TABLE FROM LANDING_T131;| ROWS_IN_THE_LANDING_TABLE |
|---|
| 0 |
Zero rows, a moment after the refresh said SENT.
That is the whole point of a pipe, and it is why pipes exist. The load happens on Snowflake's schedule, not inside your statement.
So let's wait, and ask again
The next statement in the script does nothing but wait.
SELECT SYSTEM$WAIT(60) AS WAITED;| WAITED |
|---|
| waited 60 seconds |
That is a wait, not a measurement. Nothing in this course is timed and no performance claim is being made here. We needed the load to have happened before asking, so we waited, and what came back afterwards is what you see.
SELECT COUNT(*) AS ROWS_IN_THE_LANDING_TABLE,
SUM(AMOUNT) AS TOTAL_IN_THE_LANDING_TABLE
FROM LANDING_T131;| ROWS_IN_THE_LANDING_TABLE | TOTAL_IN_THE_LANDING_TABLE |
|---|---|
| 12 | 1738.00 |
Twelve rows, and 1738.00.
The file had six rows in it and the source table added up to 869.00. Both of those numbers have doubled, and that is the most useful thing in this episode.
Twelve rows from a six row file
Let's look at the rows themselves before we guess at anything.
SELECT SALE_ID AS SALE_ID, REGION AS REGION, AMOUNT AS AMOUNT
FROM LANDING_T131
ORDER BY SALE_ID;| SALE_ID | REGION | AMOUNT |
|---|---|---|
| 1 | north | 100.00 |
| 1 | north | 100.00 |
| 2 | north | 250.50 |
| 2 | north | 250.50 |
| 3 | south | 75.25 |
| 3 | south | 75.25 |
| 4 | south | 310.00 |
| 4 | south | 310.00 |
| 5 | east | 45.00 |
| 5 | east | 45.00 |
| 6 | east | 88.25 |
| 6 | east | 88.25 |
Every sale id is in there twice. One and one, two and two, all the way down. The file was loaded twice.
Let's ask the pipe about it first.
SELECT PARSE_JSON(SYSTEM$PIPE_STATUS('PIPE_T131')):executionState::VARCHAR
AS EXECUTION_STATE,
PARSE_JSON(SYSTEM$PIPE_STATUS('PIPE_T131')):pendingFileCount::INT
AS PENDING_FILES,
PARSE_JSON(SYSTEM$PIPE_STATUS('PIPE_T131')):lastReceivedMessageTimestamp::VARCHAR
AS LAST_MESSAGE;| EXECUTION_STATE | PENDING_FILES | LAST_MESSAGE |
|---|---|---|
| RUNNING | 0 | NULL |
Running, nothing pending, and the last message is NULL for the same reason as before: there is no key by that name in the status JSON. The pipe has nothing to say about the rows that have just arrived.
So let's ask the load history about that table instead.
SELECT FILE_NAME AS THE_FILE,
ROW_COUNT AS ROWS_LOADED,
STATUS AS THE_STATUS,
PIPE_NAME AS LOADED_BY_PIPE
FROM TABLE(INFORMATION_SCHEMA.COPY_HISTORY(
TABLE_NAME => 'LANDING_T131',
START_TIME => DATEADD(HOUR, -1, CURRENT_TIMESTAMP())))
ORDER BY THE_FILE;| THE_FILE | ROWS_LOADED | THE_STATUS | LOADED_BY_PIPE |
|---|---|---|---|
| sales.csv | 6 | Loaded | PIPE_T131 |
| sales.csv | 6 | Loaded | AUTOPIPE_T131 |
Two rows. The same file name on both, six rows loaded on each, and both of them say Loaded.
The column that settles it is the last one. PIPE_NAME. One load came from PIPE_T131 and the other came from AUTOPIPE_T131.
AUTOPIPE_T131 is the second pipe. The one we created to see whether AUTO_INGEST would be refused, and then left pointed at the same prefix and the same landing table.
So the duplication is not one pipe running twice. It is two pipes each loading the file once.
Episode 126 showed COPY INTO refusing to load a file it had already loaded. That record of what has been loaded belongs to the pipe, not to the table. A second pipe over the same prefix has a record of its own, and as far as it is concerned this file is new.
Two pipes pointed at one folder will double your data, and neither one of them is doing anything wrong.
And here is what we cannot tell you. We ran REFRESH on one pipe. Only one. Both of them loaded the file. There is no capture in this episode that says how the second one was triggered, so we are not going to offer you a tidy answer. The load history says which pipes loaded the file. It does not say what set the second one going.
Can a pipe be paused?
It can, with a parameter on ALTER PIPE.
ALTER PIPE PIPE_T131 SET PIPE_EXECUTION_PAUSED = TRUE;| status |
|---|
| Statement executed successfully. |
SELECT PARSE_JSON(SYSTEM$PIPE_STATUS('PIPE_T131')):executionState::VARCHAR
AS EXECUTION_STATE;| EXECUTION_STATE |
|---|
| PAUSED |
PAUSED. Which is the reason for asking the status at all.
Now let's refresh a paused pipe. This one we expected to be refused.
ALTER PIPE PIPE_T131 REFRESH;| File | Status |
|---|---|
| sales.csv | SENT |
SENT again. The refresh is accepted either way, and the grid looks exactly the same as it did when the pipe was running.
ALTER PIPE PIPE_T131 SET PIPE_EXECUTION_PAUSED = FALSE;| status |
|---|
| Statement executed successfully. |
SELECT PARSE_JSON(SYSTEM$PIPE_STATUS('PIPE_T131')):executionState::VARCHAR
AS EXECUTION_STATE;| EXECUTION_STATE |
|---|
| RUNNING |
Running again.
And what it refuses
First, a pipe over a stage that does not exist.
CREATE OR REPLACE PIPE NOPIPE_T131 AS
COPY INTO LANDING_T131
FROM @STAGE_T131_NOPE/in/
FILE_FORMAT = (FORMAT_NAME = 'CSV_T131');002003 (02000): SQL compilation error: Stage 'DEMO_DB.PUBLIC.STAGE_T131_NOPE' does not exist or not authorized. Your primary role ACCOUNTADMIN or one of your secondary roles must have at least one privilege granted on STAGE DEMO_DB.PUBLIC.STAGE_T131_NOPE.
Refused at create time. The stage name is checked when the pipe is created, not when it runs.
Now a pipe whose body is not a COPY INTO.
CREATE OR REPLACE PIPE SELECTPIPE_T131 AS
SELECT 1 AS NOT_A_COPY;001003 (42000): SQL compilation error: syntax error line 2 at position 0 unexpected 'SELECT'.
A syntax error at the word SELECT. Notice that it is not an error about pipes at all. The grammar simply does not allow anything but a COPY INTO in there.
And asking about a pipe that is not there, three different ways.
SELECT SYSTEM$PIPE_STATUS('NO_SUCH_PIPE_T131') AS THE_STATUS;002003 (02000): SQL compilation error: Pipe 'NO_SUCH_PIPE_T131' does not exist or not authorized.
ALTER PIPE NO_SUCH_PIPE_T131 REFRESH;002003 (02000): SQL compilation error: Pipe 'DEMO_DB.PUBLIC.NO_SUCH_PIPE_T131' does not exist or not authorized. Your primary role ACCOUNTADMIN or one of your secondary roles must have at least one privilege granted on PIPE DEMO_DB.PUBLIC.NO_SUCH_PIPE_T131.
DESCRIBE PIPE NO_SUCH_PIPE_T131;002003 (02000): SQL compilation error: Pipe 'DEMO_DB.PUBLIC.NO_SUCH_PIPE_T131' does not exist or not authorized. Your primary role ACCOUNTADMIN or one of your secondary roles must have at least one privilege granted on PIPE DEMO_DB.PUBLIC.NO_SUCH_PIPE_T131.
The same code for all three, with the usual wording about an object that does not exist or is not authorized.
One last thing: the teardown
Both pipes go, then the stage, the format and the two tables.
DROP PIPE IF EXISTS PIPE_T131;| status |
|---|
| PIPE_T131 successfully dropped. |
DROP PIPE IF EXISTS AUTOPIPE_T131;| status |
|---|
| AUTOPIPE_T131 successfully dropped. |
REMOVE @STAGE_T131/;| name | result |
|---|---|
| stage_t131/in/sales.csv | removed |
DROP STAGE IF EXISTS STAGE_T131;| status |
|---|
| STAGE_T131 successfully dropped. |
DROP FILE FORMAT IF EXISTS CSV_T131;| status |
|---|
| CSV_T131 successfully dropped. |
DROP TABLE IF EXISTS LANDING_T131;| status |
|---|
| LANDING_T131 successfully dropped. |
DROP TABLE IF EXISTS SOURCE_T131;| status |
|---|
| SOURCE_T131 successfully dropped. |
And a check that nothing is left behind.
SELECT CURRENT_DATABASE() AS THE_DATABASE,
CURRENT_SCHEMA() AS THE_SCHEMA,
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES
WHERE RIGHT(TABLE_NAME, 5) = '_T131') AS PROBE_TABLES_LEFT,
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.STAGES
WHERE STAGE_NAME LIKE '%_T131%') AS PROBE_STAGES_LEFT,
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.PIPES
WHERE RIGHT(PIPE_NAME, 5) = '_T131') AS PROBE_PIPES_LEFT,
(SELECT COUNT(*) FROM CUSTOMERS) AS DEMO_DB_IS_READABLE;| THE_DATABASE | THE_SCHEMA | PROBE_TABLES_LEFT | PROBE_STAGES_LEFT | PROBE_PIPES_LEFT | DEMO_DB_IS_READABLE |
|---|---|---|---|---|---|
| DEMO_DB | PUBLIC | 0 | 0 | 0 | 10 |
No probe tables, no probe stages, no probe pipes, and the demo database still reads.
LIST @~/t131/;| name | size | md5 | last_modified |
|---|
Key points
- A pipe is a stored
COPY INTO.DESCRIBE PIPEhands the statement back word for word as its definition. AUTO_INGEST = TRUEon an internal stage is accepted, not refused. It just has nothing to listen to.SHOW PIPESreports aNULLintegration, andINFORMATION_SCHEMA.PIPESsays the same thing as the wordNOwith aNULLchannel.- In the
SHOW PIPESgrid the comment is an empty string, not aNULL. The two are not the same and the grid shows them differently. - A file landing on an internal stage triggers nothing. The table stays empty and the pipe does not know the file is there.
ALTER PIPE ... REFRESHreportsSENT, notLOADED, and the table is still empty immediately afterwards.- The load happens on Snowflake's schedule, not inside your statement.
- Asking the status JSON for a key it does not hold gives you
NULL. That is a missing key, not a measurement. - A pipe's record of what it has already loaded belongs to the pipe, not to the table. A second pipe over the same prefix loads the same file again.
COPY_HISTORYhas aPIPE_NAMEcolumn, and it is what tells you which pipes loaded a file. It does not tell you what triggered them.- A paused pipe still accepts a
REFRESH, and the grid looks identical to a running one's. - A pipe over a missing stage is refused at create time, and a pipe whose body is a
SELECTis a plain syntax error.
Episode 132 — time travel. Reading a table as it was before somebody broke it, with AT and BEFORE, and a repair of ours that put the row count back and still left the table wrong.
Every query and every result grid on this page was captured from a live Snowflake account (version 10.35.101) running the demo script for this episode. This episode writes no local files: the file the pipe loads was unloaded from a table inside the same script. The auto ingest half of Snowpipe needs cloud storage this account does not have, and the post says so rather than demonstrating it badly. The single SYSTEM$WAIT is a wait and not a measurement; nothing in this series is timed. One question this episode raises is left unanswered on purpose, and the warning beside it says which. Behaviour follows the Snowflake CREATE PIPE documentation.



No comments:
Post a Comment
Note: Only a member of this blog may post a comment.