recency
How it Works
The recency test from dbt-utils™ verifies that a model or source contains at least one row with a timestamp more recent than a specified interval from the current time. It is a straightforward freshness guard that protects downstream models and dashboards from consuming stale data.
The test is configured with a datepart (e.g., day, hour) and an interval (e.g., 1, 3), and the field argument specifies which timestamp column to evaluate.
Steps and Conditions
- Field Selection: Specify the timestamp column using
field. - Define Freshness Window: Set
datepartandinterval. - Execution: The test queries the maximum value of the specified field and checks it against
current_timestamp - interval. - Outcome: Pass if the most recent value is within the window; fail if data is stale.
Example Usage: Financial Data Platform
A financial data platform ingests market prices daily and wants to ensure the market_prices model always contains data from the current day.
models:
- name: market_prices
tests:
- dbt_utils.recency:
datepart: day
field: price_date
interval: 1If market prices have not been refreshed within the last day, the test fails and alerts the data engineering team.
Interested to Learn More? Try Out the Free 14-Days Trial
One AI-native workspace to build, ship, and monitor dbt™ — without the tool sprawl.
Join industry leaders winning with DinoAI agents
Data engineers and analysts at the most AI-native startups and enterprises use Paradime's DinoAI agents everyday to become market leaders.