GCS: Pub/Sub notifications
GCS publishes file-finalization events to Pub/Sub; a notification integration lets Snowflake consume a dedicated subscription.
Understand the idea
Choose a topic and a dedicated pull subscription. Configure bucket notifications for OBJECT_FINALIZE and incoming/m8/. Allow the bucket’s publishing identity to publish to the topic. Set subscription retention/expiration intentionally.
| Concept | What it means |
|---|---|
| Storage identity | Reads GCS objects. |
| Notification identity | Consumes the Pub/Sub subscription. |
| OBJECT_FINALIZE | Signals a completed object upload. |
| Dedicated subscription | Prevents unrelated consumers from taking Snowflake’s messages. |
A concrete example
An event for incoming/m8/batch001.json arrives through the topic and Snowflake subscription.
Remember: Storage and notification service accounts are separate; grant access to each deliberately.
Explain it step by step · full theory
Setup and reasoning
Choose a topic and a dedicated pull subscription. Configure bucket notifications for OBJECT_FINALIZE and incoming/m8/. Allow the bucket’s publishing identity to publish to the topic. Set subscription retention/expiration intentionally.
After DESC, grant the returned GCP_PUBSUB_SERVICE_ACCOUNT Pub/Sub Subscriber on the subscription. Grant the pipe owner USAGE on the integration. Several pipes may share one integration, but avoid competing integrations or applications pulling from the same subscription. M8_SOURCE must be the approved GCS stage.
Words used in this lesson
- Storage identity
- Reads GCS objects.
- Notification identity
- Consumes the Pub/Sub subscription.
- OBJECT_FINALIZE
- Signals a completed object upload.
- Dedicated subscription
- Prevents unrelated consumers from taking Snowflake’s messages.
See how it works
Choose a step to explore the idea at your own pace.
Open the interactive explanation
GCS: Pub/Sub notifications
Identify the input
GCS publishes file-finalization events to Pub/Sub; a notification integration lets Snowflake consume a dedicated subscription.
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
- Identify the input
GCS publishes file-finalization events to Pub/Sub; a notification integration lets Snowflake consume a dedicated subscription.
- Follow delivery
An event for incoming/m8/batch001.json arrives through the topic and Snowflake subscription.
- Verify and recover
Storage and notification service accounts are separate; grant access to each deliberately.
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.
- No account yet? Read and predict the output first. Follow the account and Snowsight lesson when you are ready.
- 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.
- 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. - 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.
Need the L2_OBJECTS_LAB setup? Open the first database-object lesson →
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
Manual examples only. Complete Modules 05–07 and the first lesson’s M8_LAB setup. Select L2_OBJECTS_LAB.M8_LAB in each SQL session. Replace every placeholder and choose exactly one cloud provider. Cloud IAM/notifications require authorized setup; streaming protocol outlines are explicitly non-executable. No credentials belong in this website.
Create the inbound integration and inspect its identity
CREATE NOTIFICATION INTEGRATION M8_GCS_EVENTS
TYPE=QUEUE NOTIFICATION_PROVIDER=GCP_PUBSUB ENABLED=TRUE
GCP_PUBSUB_SUBSCRIPTION_NAME='projects/<project>/subscriptions/<subscription>';
DESC NOTIFICATION INTEGRATION M8_GCS_EVENTS;
-- After GCP IAM is configured, grant to your existing pipe-owner role:
-- GRANT USAGE ON INTEGRATION M8_GCS_EVENTS TO ROLE <pipe_owner>;What to expect and why
Requires integration-creation privileges. Complete subscription IAM before creating the pipe.
Create the GCS pipe
CREATE PIPE M8_AUTO_PIPE AUTO_INGEST=TRUE INTEGRATION='M8_GCS_EVENTS' AS
COPY INTO L2_OBJECTS_LAB.M8_LAB.M8_FILE_EVENTS
FROM @L2_OBJECTS_LAB.M8_LAB.M8_SOURCE
FILE_FORMAT=(FORMAT_NAME='L2_OBJECTS_LAB.M8_LAB.M8_JSON');What to expect and why
Use this provider branch instead of AWS/Azure. The integration string matches the stored uppercase name.
Check your understanding
Choose an answer, then check your reasoning. This is practice, not a scored test.
Try it yourself
A queue event arrives but object reads fail. Which identity needs investigation?
Compare your reasoning
The storage integration’s identity and bucket access, not just the notification service account.