Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Track dimension history with SCD Type 2

Convert an overwrite-style dimension model to SCD_TYPE_2 so changes are versioned with valid_from/valid_to instead of lost on the next run.

An INCREMENTAL_BY_UNIQUE_KEY or FULL dimension model keeps only the current value of a row. The moment a customer's plan tier changes, the old value is gone, overwritten by the next merge or rebuild. That's fine when only "what is true right now" matters. It breaks the moment someone asks "what was this customer's plan tier last quarter," or a downstream report needs to attribute revenue to the tier that was active at the time, not the tier that's active today.

Use this recipe when a dimension changes over time and something downstream needs the history, not just the latest snapshot: a customer profile, a subscription plan, a product price; anywhere "what changed and when" matters as much as "what is it now."

Before you begin

  • An existing dimension model (FULL or INCREMENTAL_BY_UNIQUE_KEY) you want to convert, or a source table you're modeling for the first time.

  • Know whether the source table has a reliable "last changed" timestamp column (updated_at, modified_at, or similar). This decides which SCD2 variant you use.

  • A unique key for the dimension (e.g. customer_id). SCD2 needs one, same as INCREMENTAL_BY_UNIQUE_KEY does.

Steps

1. Confirm SCD2 is the right kind

Three kinds compete for the same "dimension table" job. Pick based on whether you need history, not just habit:

Kind
Behavior
Use when

FULL

Rebuilds the whole table every run

Table is small and cheap to rebuild; you only ever need "now"

INCREMENTAL_BY_UNIQUE_KEY

Upserts on a key; old value is gone once updated

You need "now" only, but the table is too large to rebuild fully each run

SCD_TYPE_2

Upserts on a key, but keeps every prior version with valid_from/valid_to

Something downstream needs "what was true at time X," not just "what's true now"

If nothing downstream ever queries a historical value, INCREMENTAL_BY_UNIQUE_KEY is simpler and cheaper. Don't reach for SCD2 by default.

2. Pick a change-detection strategy: by time or by column

Vulcan detects changes two ways:

  • SCD_TYPE_2_BY_TIME (recommended): reads an "updated at" column from the source and uses it as the real change timestamp. valid_from reflects when the source system actually changed the record.

  • SCD_TYPE_2_BY_COLUMN: watches a list of columns for value changes between runs when the source has no update timestamp. valid_from reflects when Vulcan detected the change, not when it actually happened.

If the source has any kind of "last modified" column, use BY_TIME. Only fall back to BY_COLUMN when the source genuinely can't tell you when a value changed.

3. Convert the model definition

Starting point. An overwrite-style customer dimension using INCREMENTAL_BY_UNIQUE_KEY:

Convert it to SCD_TYPE_2_BY_TIME. Notice the query doesn't change at all. Only the kind block does:

If raw.customers has no updated_at column, use SCD_TYPE_2_BY_COLUMN instead and list the columns to watch explicitly:

Either variant adds valid_from and valid_to columns to the materialized table automatically. Don't declare them yourself.

4. Run vulcan plan and expect a full backfill

Switching a model's kind (from INCREMENTAL_BY_UNIQUE_KEY to SCD_TYPE_2_BY_TIME, for instance) is a breaking change. vulcan plan recreates the physical table from scratch and backfills it in full, adding valid_from/valid_to for every existing row (rows present before the switch get valid_from set to the epoch, not their real creation time, since that information doesn't exist yet).

Review the plan output before applying: confirm it's showing a full rebuild of this one model, not an unexpected ripple into unrelated downstream models. This is also why SCD2 doesn't support partial restatement afterward: any future restatement of this model recreates the whole table again, the same way the initial conversion does. Vulcan disables restatement by default for exactly this reason; a future restatement on this model only runs after you explicitly add disable_restatement false to its kind block.

5. Verify history with a query

Say raw.customers changes over three runs:

Run date

plan_tier

2026-01-01

free

2026-01-02

pro

2026-01-03

enterprise

After the third run, warehouse.dim_customer_profile for customer_id = 42 looks like this:

customer_id
plan_tier
updated_at
valid_from
valid_to

42

free

2026-01-01

1970-01-01 00:00:00

2026-01-02 00:00:00

42

pro

2026-01-02

2026-01-02 00:00:00

2026-01-03 00:00:00

42

enterprise

2026-01-03

2026-01-03 00:00:00

NULL

The current row (valid_to IS NULL):

What the customer's tier was at a point in the past. This is the query overwrite-style models can never answer:

6. Decide how hard deletes should behave (optional)

If a row disappears from the source entirely, invalidate_hard_deletes controls whether that counts as "deleted at this timestamp" (true) or "still valid, no gap in history" (false, the default). Set it explicitly rather than relying on the default if deletion timing matters to your use case:

Best practices

  • Prefer BY_TIME whenever the source has any reliable "last changed" column. valid_from is only as accurate as the signal you give it.

  • Set grains on the unique key so downstream models and the catalog know the row identity, same as any other dimension model.

  • Expect a full backfill the first time you switch a model to SCD2. Don't schedule the switch during a window when a large rebuild would collide with other production runs.

  • Never treat valid_to = NULL as "row deleted." It means "still current" (the opposite).

  • Bound point-in-time queries on both valid_from and valid_to. Filtering only on valid_to IS NULL silently drops into "current state only," which defeats the purpose of using SCD2 in the first place.

Troubleshooting

Symptom
Likely cause
Fix

Every plan fully rebuilds the table, even for a tiny data change

Expected behavior for SCD2: no partial restatement is supported

Confirm this cost is acceptable before adopting SCD2 for very large or fast-changing sources

valid_from doesn't match when the change "really" happened

Model uses BY_COLUMN, which stamps valid_from at detection time, not source change time

Switch to BY_TIME if the source has (or can add) an updated_at-style column

A deleted-then-reinserted record shows an unexpected gap, or no gap at all

invalidate_hard_deletes doesn't match your expectation

Set invalidate_hard_deletes explicitly instead of relying on the default

A query returns more than one "current" row for the same key

unique_key doesn't actually identify one row per key

Re-check unique_key against the source data and the model's grains

vulcan plan triggers a much bigger rebuild than expected when switching kinds

Switching to (or between) SCD2 variants is inherently a full-table operation

Expect and schedule for the full rebuild: this isn't a partial-migration path

A restatement on an SCD2 model is refused or has no effect

Vulcan disables restatement by default for SCD2 models, since a restatement recreates the whole table and can lose history

Add disable_restatement false to the model's kind block only when you intentionally want to restate, then remove it afterward

References

  • Model kinds - full SCD_TYPE_2_BY_TIME / SCD_TYPE_2_BY_COLUMN reference, including deletes and column-renaming options.

  • Properties - the general MODEL DDL property reference.

Last updated

Was this helpful?