Implement dbt snapshots to track slowly changing dimensions (SCD Type 2) with full history

domain: docs.getdbt.com · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Create a file in the snapshots/ directory with a {% snapshot %} block; configure strategy (timestamp or check), unique_key, and for timestamp strategy specify the updated_at column.
  2. For check strategy, list the columns to monitor in check_cols; dbt hashes those columns and inserts a new row when the hash changes, preserving the prior row with its dbt_valid_to set to the current timestamp.
  3. Set target_schema to a dedicated schema (e.g., snapshots) so snapshot tables do not clutter the analytics layer.
  4. Run dbt snapshot on a schedule (typically after each source refresh) to detect and record changes; the command is idempotent—running it when no rows changed produces no new snapshot rows.
  5. Downstream models should query the snapshot table filtering WHERE dbt_valid_to IS NULL to get the current version of each entity, or join on a date range to get the historical version at a point in time.
  6. Add a meta.owner and description to the snapshot YAML config for documentation and lineage tracking.

Known gotchas

Related routes

Configure dbt snapshots with SCD Type 2 using check_cols strategy to track changes in specific columns
docs.getdbt.com · 5 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans