updated_at
snapshots:
<resource-path>:
+strategy: timestamp
+updated_at: column_name
Description
A column within the results of your snapshot query that represents when the record row was last updated.
This parameter is required if using the timestamp
strategy. The updated_at
field may support ISO date strings and unix epoch integers, depending on the data platform you use.
Default
No default is provided.
Examples
Use a column name updated_at
Coalesce two columns to create a reliable updated_at
column
Consider a data source that only has an updated_at
column filled in when a record is updated (so a null
value indicates that the record hasn't been updated after it was created).
Since the updated_at
configuration only takes a column name, rather than an expression, you should update your snapshot query to include the coalesced column.
Using updated_at with check strategy
When using the check strategy, dbt verifies the rows in the source table based on a timestamp column to determine freshness. By default, it uses the updated_at
column if it's explicitly configured. If the updated_at
column isn't configured, dbt falls back to using the current timestamp for all rows.
Check out the following example showing how to configure the updated_at
column for the check strategy:
sources:
- name: my_source
tables:
- name: my_table
freshness:
warn_after: {count: 12, period: hour}
error_after: {count: 24, period: hour}
strategy: check
updated_at: updated_at_column_name
In this example:
strategy
: check tells dbt to use theupdated_at
column for verifying row freshness.updated_at
:updated_at_column_name
explicitly sets the column (pdated_at_column_name
) to be used for the freshness checks. If theupdated_at_column_name
column isn't present in the source table, dbt will fall back to the current timestamp for all rows.