Course
dbt Analytics EngineerDeveloping dbt ModelsSnapshots
0%
Recording historyPage 1

What a dbt snapshot records

Snapshots let dbt keep a history of how a row changes over time. Normally, updating a source row replaces its previous values. A snapshot keeps successive versions of that row, so you can see what was true at different times.

Start with one customer

Suppose customer 7 currently has the status active. The source stores one row for this customer, with customer_id = 7 and status = active.

One source row, two historical versions

  1. 09:00 · first snapshot runcustomer_id=7 · status=active

    The snapshot saves the active state.

  2. 11:00 · snapshot runs after the updatecustomer_id=7 · status=paused

    The source now holds paused. The snapshot keeps both versions.

Snapshot history after both captures
customer  status  period
7         active  09:00–11:00
7         paused  11:00 onward

The source still has one current row. In a separate table, the snapshot keeps both versions of customer 7, each for a different period. This is SCD Type 2: a type 2 slowly changing dimension.

Follow the record through the system

Next, we'll run the snapshot several times and watch what happens as this source row changes.

History must be captured before it disappears

A view or rebuilt table reads the source as it is now; an incremental merge normally updates its saved row. None automatically retains every earlier version. A snapshot cannot recover a value overwritten before its first capture.

Restoring your place