Skip to main content

strategy

dbt_project.yml
snapshots:
<resource-path>:
+strategy: timestamp
+updated_at: column_name

Description

The snapshot strategy dbt should use to detect record changes. Read the guide to snapshots to understand the differences between the two.

Default

This is a required configuration. There is no default value.

Examples

Use the timestamp strategy

Use the check strategy

Advanced: define and use custom snapshot strategy

Behind the scenes, snapshot strategies are implemented as macros, named snapshot_<strategy>_strategy

It's possible to implement your own snapshot strategy by adding a macro with the same naming pattern to your project. For example, you might choose to create a strategy which records hard deletes, named timestamp_with_deletes.

  1. Create a macro named snapshot_timestamp_with_deletes_strategy. Use the existing code as a guide and adjust as needed.
  2. Use this strategy via the strategy configuration:
0