dbt Tests

expect_row_values_to_have_recent_data

dbt-expectations

·

Model,Source

·

Freshness

How it Works

The expect_row_values_to_have_recent_data test from the dbt-expectations package checks that a model or source contains at least one row whose timestamp column value falls within a recent time window. This is a critical freshness check to detect pipeline staleness before downstream consumers notice.

The recency window is defined by datepart and interval arguments (e.g., the last 1 day or last 3 hours).

Steps and Conditions

  1. Column Selection: Identify the timestamp column to evaluate.

  2. Define Recency Window: Set the datepart (e.g., day, hour) and interval (e.g., 1, 6).

  3. Execution: The test checks whether any row has a timestamp within the window relative to the current time.

  4. Outcome: Pass if at least one recent row exists; fail if all data is stale.

Example Usage: IoT Platform

An IoT platform ingests device telemetry every hour. The team wants to ensure the device_telemetry table always has data from the last 2 hours.

models:
  - name: device_telemetry
    columns:
      - name: recorded_at
        tests:
          - dbt_expectations.expect_row_values_to_have_recent_data:
              datepart: hour
              interval: 2
models:
  - name: device_telemetry
    columns:
      - name: recorded_at
        tests:
          - dbt_expectations.expect_row_values_to_have_recent_data:
              datepart: hour
              interval: 2
models:
  - name: device_telemetry
    columns:
      - name: recorded_at
        tests:
          - dbt_expectations.expect_row_values_to_have_recent_data:
              datepart: hour
              interval: 2

If no data has arrived in the last 2 hours, the test fails and triggers an alert.

Interested to Learn More?
Try Out the Free 14-Days Trial

Stop Managing Pipelines. Start Shipping Them.

Join the teams that replaced manual dbt™ workflows with agentic AI. Free to start, no credit card required.

Stop Managing Pipelines. Start Shipping Them.

Join the teams that replaced manual dbt™ workflows with agentic AI. Free to start, no credit card required.

Stop Managing Pipelines. Start Shipping Them.

Join the teams that replaced manual dbt™ workflows with agentic AI. Free to start, no credit card required.

Copyright © 2026 Paradime Labs, Inc. Made with ❤️ in San Francisco ・ London

*dbt® and dbt Core® are federally registered trademarks of dbt Labs, Inc. in the United States and various jurisdictions around the world. Paradime is not a partner of dbt Labs. All rights therein are reserved to dbt Labs. Paradime is not a product or service of or endorsed by dbt Labs, Inc.

Copyright © 2026 Paradime Labs, Inc. Made with ❤️ in San Francisco ・ London

*dbt® and dbt Core® are federally registered trademarks of dbt Labs, Inc. in the United States and various jurisdictions around the world. Paradime is not a partner of dbt Labs. All rights therein are reserved to dbt Labs. Paradime is not a product or service of or endorsed by dbt Labs, Inc.

Copyright © 2026 Paradime Labs, Inc. Made with ❤️ in San Francisco ・ London

*dbt® and dbt Core® are federally registered trademarks of dbt Labs, Inc. in the United States and various jurisdictions around the world. Paradime is not a partner of dbt Labs. All rights therein are reserved to dbt Labs. Paradime is not a product or service of or endorsed by dbt Labs, Inc.