To create a Snowpipe, you need to use the CREATE PIPE
statement. The syntax for the CREATE PIPE
statement is as follows:
CREATE PIPE pipe_name
(
COPY INTO table_name
FROM stage_name
OPTIONS (
file_format = file_format_name,
staging_parallelism = number_of_threads,
ingestion_parallelism = number_of_threads
)
);
The pipe_name
parameter is the name of the Snowpipe.
The table_name
parameter is the name of the table in Snowflake that you want to load the data into.
The stage_name
parameter is the name of the stage in Snowflake that contains the data files.
The file_format_name
parameter is the name of the file format that the data files are in.
The staging_parallelism
parameter is the number of threads that Snowpipe will use to stage the data files.
The ingestion_parallelism
parameter is the number of threads that Snowpipe will use to ingest the data files into the table.
Here is an example of how to create a Snowpipe:
CREATE PIPE my_pipe
(
COPY INTO my_table
FROM my_stage
OPTIONS (
file_format = csv,
staging_parallelism = 4,
ingestion_parallelism = 8
)
);
This will create a Snowpipe called my_pipe
that will load data from the my_stage
stage into the my_table
table. The data files in the my_stage
stage must be in CSV format. Snowpipe will use 4 threads to stage the data files and 8 threads to ingest the data files into the table.
Once you have created a Snowpipe, you can start loading data into Snowflake. You can do this by either manually triggering the Snowpipe or by configuring it to load data automatically.