unique_key
snapshots:
<resource-path>:
+unique_key: column_name_or_expression
Description
A column name or expression that is unique for the inputs of a snapshot. dbt uses this to match records between a result set and an existing snapshot, so that changes can be captured correctly.
In dbt Cloud "Latest" and dbt v1.9+, snapshots are defined and configured in YAML files within your snapshots/
directory. You can specify one or multiple unique_key
values within your snapshot YAML file's config
key.
Providing a non-unique key will result in unexpected snapshot results. dbt will not test the uniqueness of this key, consider testing the source data to ensure that this key is indeed unique.
Default
This is a required parameter. No default is provided.
Examples
Use an id
column as a unique key
You can also specify configurations in your dbt_project.yml
file if multiple snapshots share the same unique_key
:
snapshots:
<resource-path>:
+unique_key: id