How Snowflake Streams track INSERTs, UPDATEs and DELETEs: standard vs append-only streams and offset consumption
Quick Overview
Asks how Snowflake streams capture inserts, updates and deletes on a source table, how standard and append-only streams differ, and when a stream's changes count as consumed. Tests change data capture concepts, offsets, staleness and how to apply changes downstream.
How Snowflake Streams track INSERTs, UPDATEs and DELETEs: standard vs append-only streams and offset consumption
Role: Data Scientist
Category: Data Manipulation (SQL/Python)
Difficulty: medium
Interview Round: Other
Explain how streams in Snowflake track changes (INSERTs, UPDATEs, DELETEs) to source tables, including the different stream types (standard, append-only) and the consumption contract: what a stream returns, and when the changes it shows are considered consumed.
```hint What the stream remembers
Think about what a stream has to store to know which changes you have not processed yet, and which kind of statement should move that marker forward.
```
### What a Strong Answer Covers
- What a stream stores and what a query against it returns, including the metadata columns and how an UPDATE appears
- The difference between standard and append-only streams, with an example where they return different rows
- Exactly which statements advance the offset, and what happens inside a transaction
- Staleness: why a stream can become unusable and how to prevent it
- How a downstream job applies the stream's rows to a target table
### Follow-up Questions
- A row is inserted and then deleted before the stream is consumed. What does a standard stream show, and what does an append-only stream show?
- How would you schedule a task that runs only when a stream has new data?
- Two different pipelines need the same table's changes. How do you set that up so neither one steals the other's changes?
- Your stream went stale over a long weekend. How do you recover without losing or double-counting changes?
Overview: Asks how Snowflake streams capture inserts, updates and deletes on a source table, how standard and append-only streams differ, and when a stream's changes count as consumed. Tests change data capture concepts, offsets, staleness and how to apply changes downstream.
Explain how streams in Snowflake track changes (INSERTs, UPDATEs, DELETEs) to source tables, including the different stream types (standard, append-only) and the consumption contract: what a stream returns, and when the changes it shows are considered consumed.
What a Strong Answer Covers Guidance
What a stream stores and what a query against it returns, including the metadata columns and how an UPDATE appears
The difference between standard and append-only streams, with an example where they return different rows
Exactly which statements advance the offset, and what happens inside a transaction
Staleness: why a stream can become unusable and how to prevent it
How a downstream job applies the stream's rows to a target table
Follow-up Questions Guidance
A row is inserted and then deleted before the stream is consumed. What does a standard stream show, and what does an append-only stream show?
How would you schedule a task that runs only when a stream has new data?
Two different pipelines need the same table's changes. How do you set that up so neither one steals the other's changes?
Your stream went stale over a long weekend. How do you recover without losing or double-counting changes?