CREATE PIPE
statementsupportedData loading & unloadingCreates a new pipe in the system for defining the COPY INTO <table> statement used by Snowpipe to load data from an ingestion queue, or by Snowpipe Streaming with high-performance architecture to load data from a streaming source directly into tables. This command supports the following variants: - CREATE OR ALTER PIPE: Creates a pipe if it doesn’t exist or alters an existing pipe. - DEFINE PIPE: Declarative definition of a pipe’s target state inside a DCM project.
Syntax
supportedpartialnot supportednot scored
CREATE [ OR REPLACE ] PIPE [ IF NOT EXISTS ] <name>
[ AUTO_INGEST = [ TRUE | FALSE ] ]
[ ERROR_INTEGRATION = <integration_name> ]
[ AWS_SNS_TOPIC = '<string>' ]
[ INTEGRATION = '<string>' ]
[ COMMENT = '<string_literal>' ]
AS <copy_statement>
For more information, see CREATE OR ALTER <object>.
CREATE OR ALTER PIPE <name>
[ AUTO_INGEST = [ TRUE | FALSE ] ]
[ ERROR_INTEGRATION = <integration_name> ]
[ AWS_SNS_TOPIC = '<string>' ]
[ INTEGRATION = '<string>' ]
[ PIPE_EXECUTION_PAUSED = TRUE | FALSE ]
[ COMMENT = '<string_literal>' ]
AS <copy_statement>
Parameters
| Name | Required | Description |
|---|---|---|
name | required | Identifier for the pipe; must be unique for the schema in which the pipe is created. The identifier must start with an alphabetic character and cannot contain spaces or special characters unless the entire identifier string is enclosed in double quotes (e.g. "My object"). Identifiers enclosed in double quotes are also case-sensitive. For more details, see Identifier requirements. |
copy_statement | required | COPY INTO <table> statement used to load data from queued files into a Snowflake table. This statement serves as the text/definition for the pipe and is displayed in the SHOW PIPES output. |
AUTO_INGEST = TRUE | FALSE | optional | Specifies whether to automatically load data files from the internal or external stage: TRUE enables automatic data loading. Snowpipe supports loading from external stages (Amazon S3, Google Cloud Storage, or Microsoft Azure). FALSE disables automatic data loading. You must make calls to the Snowpipe REST API endpoints to load data files. Snowpipe supports loading from internal stages (i.e. Snowflake named stages or table stages, but not user stages) or external stage (Amazon S3, Google Cloud Storage, or Microsoft Azure). |
ERROR_INTEGRATION = integration_name | optional | Required only when configuring Snowpipe to send error notifications to a cloud messaging service. Specifies the name of the notification integration used to communicate with the messaging service. For more information, see Snowpipe error notifications. |
AWS_SNS_TOPIC = 'string' | optional | Required only when configuring AUTO_INGEST for Amazon S3 external stages using SNS. Specifies the Amazon Resource Name (ARN) for the SNS topic for your S3 bucket. The CREATE PIPE statement subscribes the Amazon Simple Queue Service (SQS) queue to the specified SNS topic. The pipe copies files to the ingest queue triggered by event notifications via the SNS topic. For more information, see Automate Snowpipe for Amazon S3. You can’t specify both AWS_SNS_TOPIC and INTEGRATION for an Amazon S3 stage. |
INTEGRATION = 'string' | optional | Required only when configuring AUTO_INGEST for Google Cloud Storage or Microsoft Azure external stages, or for an Amazon S3 external stage when the pipe uses a Multi-Queue Notification Integration. Specifies the existing notification integration used to access the storage queue. For an Amazon S3 stage, specify a Multi-Queue Notification Integration, and don’t specify AWS_SNS_TOPIC. For more information, see: Automate Snowpipe for Google Cloud Storage Automate Snowpipe for Microsoft Azure Blob Storage Create a Multi-Queue Notification Integration for multi-location resilience The integration name must be typed in all uppercase. |
COMMENT = 'string_literal' | optional | Specifies a comment for the pipe. Default: No value |
Usage notes
- This SQL command requires the following minimum permissions: Privilege Object Notes CREATE PIPE Schema USAGE Stage in the pipe definition External stages only USAGE Integration Required for the notification integrations that the pipe references in INTEGRATION or ERROR_INTEGRATION READ Stage in the pipe definition Internal stages only INSERT Table in the pipe definition USAGE Named file format in the pipe definition Only if the pipe uses a named file format OWNERSHIP Pipe Required to execute a CREATE OR ALTER PIPE statement for an existing pipe. SQL operations on schema objects also require USAGE or any other privilege on the database and schema that contain the object. ExpandShow lessSee more
- All COPY INTO <table> copy options are supported except for the following: FILES = ( 'file_name1' [ , 'file_name2', ... ] )
- ON_ERROR = ABORT_STATEMENT
- SIZE_LIMIT = num
- PURGE = TRUE | FALSE (i.e. automatic purging while loading)
- FORCE = TRUE | FALSE Note that you can manually remove files from an internal (i.e. Snowflake) stage (after they’ve been loaded) using the REMOVE command.
- LOAD_UNCERTAIN_FILES = TRUE | FALSE
- RETURN_FAILED_ONLY = TRUE | FALSE
- VALIDATION_MODE = RETURN_n_ROWS | RETURN_ERRORS | RETURN_ALL_ERRORS
- If error logging is turned on for the target table, the pipe’s ON_ERROR value determines which errors from CSV, JSON, and Parquet files are recorded in the table’s error table: With ON_ERROR = SKIP_FILE (the default), only one error is recorded for each skipped file.
- With ON_ERROR = CONTINUE, every rejected row is recorded.
- With ON_ERROR = SKIP_FILE_<num> or ON_ERROR = 'SKIP_FILE_<num>%', error logging isn’t supported, and the error table might contain no errors or only some errors from the pipe.
- With ON_ERROR = CONTINUE, the pipe loads the valid rows from each file, and it doesn’t send error notifications or record FAILED events for files that it loads partially. To choose a value, see Choose an ON_ERROR value for a pipe. To change the ON_ERROR value later, you must recreate the pipe.
- Add CHECK constraints to the target table before you create the pipe. After you create a pipe that loads files from a stage, you can’t add a CHECK constraint to the target table, or drop or change a CHECK constraint on it, even if you pause the pipe. To change the constraints, follow the steps in Change the CHECK constraints on a table that a pipe loads, which drop the pipe and create it again without skipping files or loading them twice.
- If a pipe uses the INFER_NESTED_TYPES copy option, the role that owns the pipe needs the EVOLVE SCHEMA or OWNERSHIP privilege on the target table. CREATE PIPE fails if the copy_statement combines the option with a SELECT transform. To add the option to an existing pipe, see Add INFER_NESTED_TYPES to an existing load.
- The PATTERN = 'regex_pattern' copy option filters the set of files to load using a regular expression. Pattern matching behaves as follows depending on the AUTO_INGEST parameter value: AUTO_INGEST = TRUE: The regular expression filters the list of files in the stage and optional path (i.e. cloud storage location) in the COPY INTO <table> statement.
- AUTO_INGEST = FALSE: The regular expression filters the list of files submitted in calls to the Snowpipe REST API insertFiles endpoint.
- Snowpipe trims any path segments in the stage definition from the storage location and applies the regular expression to any remaining path segments and filenames. To view the stage definition, execute the DESCRIBE STAGE command for the stage. The URL property consists of the bucket or container name and zero or more path segments. For example, if the FROM location in a COPY INTO <table> statement is @s/path1/path2/ and the URL value for stage @s is s3://mybucket/path1/, then Snowpipe trims s3://mybucket/path1/path2/ from the storage location in the FROM clause and applies the regular expression to the remaining filenames in the path.
- Important
- Snowflake recommends that you enable cloud event filtering for Snowpipe to reduce costs, event noise, and latency. Only use the PATTERN option when your cloud provider’s event filtering feature is not sufficient. For more information about configuring event filtering for each cloud provider, see the following pages:
- Amazon S3: Configuring event notifications using object key name filtering
- Microsoft Azure Event Grid: Understand event filtering for Event Grid subscriptions
- Google Cloud Pub/Sub: Filtering messages
- Using a query as the source for the COPY statement for column reordering, column omission, and casts (i.e. transforming data during a load) is supported. For usage examples, see Transform data during a load. Note that only simple SELECT statements are supported. Filtering using a WHERE clause is not supported.
- Pipe definitions are not dynamic (i.e. a pipe is not automatically updated if the underlying stage or table changes, such as renaming or dropping the stage/table). Instead, you must create a new pipe and submit this pipe name in future Snowpipe REST API calls.
- Regarding metadata: Attention Customers should ensure that no personal data (other than for a User object), sensitive data, export-controlled data, or other regulated data is entered as metadata when using the Snowflake service. For more information, see Metadata fields in Snowflake.
- The OR REPLACE and IF NOT EXISTS clauses are mutually exclusive. They can’t both be used in the same statement.
- CREATE OR REPLACE <object> statements are atomic. That is, when an object is replaced, the old object is deleted and the new object is created in a single transaction.
- Important
- If you recreate a pipe (using the CREATE OR REPLACE PIPE syntax), see Change or recreate a pipe for related considerations and best practices.
- All limitations of the ALTER PIPE command apply.
- The pipe’s COPY INTO statement (copy_statement) can’t be changed for an existing pipe. If you need to change the pipe definition, drop the existing pipe and create a new one. See Change or recreate a pipe for related considerations.
- The AUTO_INGEST, AWS_SNS_TOPIC, and INTEGRATION properties can’t be changed for an existing pipe.
- Setting or unsetting a tag is not supported.
Pipes for Snowpipe Streaming with high-performance architecture
You can define a pipe for Snowpipe Streaming to load data directly from the Snowpipe Streaming API, without requiring a staged file location. This method is designed for low-latency, row-based ingestion. The COPY INTO statement for a streaming pipe must use the DATA_SOURCE table function in the FROM clause, with the TYPE => 'STREAMING' argument. Note - Pipes created for streaming don’t require an AUTO_INGEST parameter or a FROM @stage clause. - The copy_statement within a streaming pipe’s definition is used to transform and load the data received from the API. - Snowpipe Streaming also provides a default pipe for each table, which is automatically created on demand. You only need to create a custom pipe if you require features like in-flight transformations or pre-clustering. For examples, see CREATE OR ALTER PIPE.