Videos

Snowflake Demo: Event-Driven Data Ingestion with Snowpipe

How Snowpipe with Google Cloud Storage works

Most pipelines run on a schedule, so data is often stale by the time it reaches the warehouse. In this demo, Pallari builds an event-driven pipeline using Snowpipe and Google Cloud Storage. New files load into Snowflake within seconds of landing in the bucket, with no scheduled jobs or manual reruns.

Here’s the flow:

  1. A file is uploaded to a Google Cloud Storage bucket.
  2. The upload sends an event to Google Cloud Pub/Sub.
  3. Snowflake picks up that event through a notification integration.
  4. Snowpipe loads the new file into the target table automatically.

What you need before you start: a Google Cloud project, a Snowflake account with admin-level access, and a virtual warehouse.

Step 1: Create a Google Cloud Storage bucket (2:12)

Pallari creates a storage bucket in Google Cloud and uploads a few sample CSV files of logistics data. This bucket is where new data will land.

Step 2: Set up the database and schema in Snowflake (3:40)

In a new Snowflake SQL notebook, she creates the database and schema that will hold the target table.

Step 3: Create the storage integration (5:13)

A storage integration lets Snowflake read from the bucket securely, with no cloud credentials stored in Snowflake. Once it’s created, Snowflake generates a Google Cloud service account to use in the next step.

Step 4: Give Snowflake access to the bucket (9:02)

Back in Google Cloud, Pallari creates a custom IAM role with read permissions for the bucket and its files. She then adds the Snowflake service account to the bucket and assigns it that role.

Step 5: Create the external stage (13:21)

The stage connects Snowflake to the bucket through the storage integration. Once it’s created, the uploaded files show up in Snowflake’s Database Explorer. You could load data from here by running a load command by hand every time, and the next steps automate that with Snowpipe.

Step 6: Set up Pub/Sub notifications (18:10)

Using Google Cloud Shell, Pallari sets up a notification that sends an event to a Pub/Sub topic each time a new file is added to the bucket. She then creates a subscription to that topic, which Snowflake will listen to.

Step 7: Create the notification integration (21:26)

In Snowflake, she creates a notification integration that connects to the Pub/Sub subscription. This is how Snowflake learns that new data has arrived. It also generates a second service account for Google Cloud.

Step 8: Grant Pub/Sub permissions (22:43)

In Google Cloud, Pallari gives the new service account two roles: Pub/Sub Subscriber on the subscription, and Monitoring Viewer at the project level.

Step 9: Create the target table with schema inference (24:33)

She doesn’t define the table columns by hand. Snowflake’s schema inference reads the file headers, infers the data types and builds the table automatically.

Step 10: Create the Snowpipe with auto-ingest (27:04)

Next, Pallari creates the pipe and turns on auto-ingest, which is what makes the pipeline event-driven. Each time Pub/Sub reports a new file, Snowpipe loads it into the logistics table with no manual step.

Step 11: Test it with a new file (29:38)

The first load brings in 30 records. Pallari then uploads a second file with 30 more rows. Without rerunning anything, the table shows 60 records a few seconds later. Whether you upload one file or a whole folder, Snowpipe picks it up.

Key takeaways

  • Event-driven loading cuts latency. Snowpipe loads files as they arrive, with no scheduled jobs or manual reruns.
  • Integrations keep access secure. Storage and notification integrations use Google Cloud service accounts, so no credentials are stored in Snowflake.
  • Schema inference speeds up setup. Snowflake can build the target table straight from your file headers.

 

Frequently asked questions

How fast does Snowpipe load files from Google Cloud Storage?
Usually within seconds to a minute of the file landing in the bucket, depending on file size and volume.

Do I need to rerun the pipeline when new files arrive?
No. With auto-ingest turned on, Pub/Sub notifies Snowflake, and Snowpipe loads each new file automatically.

What Google Cloud services does this use?
Cloud Storage for the files, Pub/Sub for the event notifications, and IAM to give Snowflake access to both.

Need help modernizing your data ingestion? Green Leaf is a Snowflake Select Services Partner. Talk to our Data Platform & Strategy team.

Watch the full demo below!