Configuring a snapshot to track slowly changing data
As of dbt v1.9+, snapshots can be defined in YAML files under a snapshots: key, similar to how sources and models are configured, rather than only using the legacy Jinja/SQL snapshot block syntax. YAML snapshots use select to define the query (often referencing a source or model) and require a config block for strategy, unique_key, and check/timestamp columns. This objective tests your ability to correctly structure and configure a YAML-based snapshot definition.
1 · Learn the must-know
- YAML snapshots are defined in .yml files under a
snapshots:top-level key, with each snapshot having anameand arelationorselectpointing to the source table. - Required config fields are
strategy(timestamp or check),unique_key, and eitherupdated_at(for timestamp strategy) orcheck_cols(for check strategy). - The
target_schemaconfig is deprecated in favor of letting snapshots follow the same custom schema logic as models; useschemaconfig orgenerate_schema_namemacro instead when applicable. - You can still use the legacy
.sqlsnapshot block syntax with{% snapshot %}...{% endsnapshot %}, but YAML snapshots are the current recommended approach and both cannot define the same snapshot simultaneously. - Snapshots configured in YAML support the same config options as SQL-defined snapshots, including
invalidate_hard_deletes,strategy, andunique_key, and can also be configured viadbt_project.ymlunder thesnapshots:key for project-wide defaults. - A common gotcha: the
select(orrelation) in a YAML snapshot must resolve to a single table/query representing the mutable source data being tracked—snapshots still cannot be built on ephemeral models.
2 · Check your understanding
You are configuring a new snapshot in a YAML file located in your snapshots/ directory. The source table has a reliable updated_at column that changes every time a row is modified. Which YAML config block correctly defines this snapshot using the timestamp strategy?
What you have tried across dbt Analytics Engineering's objectives, not a readiness score.
Developing and optimizing dbt models45.16% of the exam*0 of 14 tried
Managing dbt models governance9.68% of the exam*0 of 3 tried
Debugging data modeling errors16.13% of the exam*0 of 5 tried
Troubleshooting and optimizing dbt pipelines6.45% of the exam*0 of 2 tried
Implementing dbt tests9.68% of the exam*0 of 3 tried
Implementing and maintaining external dependencies6.45% of the exam*0 of 2 tried
Leveraging the dbt state6.45% of the exam*0 of 2 tried
* Our estimate. dbt Labs publishes no section weights.
3 · Keep going
Ready for more? Take a weighted mock or try free practice questions.