⚙️dbt Snapshot
Also known as dbt Snapshots
A dbt table that keeps each old version of a row that changes.
Think of it like
It is like a height chart on a door frame. Each new mark is added, and the old marks stay.
Example
An order goes from pending on 1 January to shipped on 2 January. The snapshot keeps both rows, each with the dates it was true.
Why it matters
Many source tables overwrite old values. Without a snapshot, the past is gone for good.
Definition
Example code
yaml
snapshots:
- name: orders_snapshot
relation: source('shop', 'orders')
config:
unique_key: id
strategy: timestamp
updated_at: updated_atCommon mistake
Key takeaways
- 1Never overwrite. A change adds a row.
- 2Valid from and to. Each version has its own dates.
- 3Run on a schedule. Only changes seen at a run are kept.