dbt · Testing & Documentation

Source freshness

Mediumsource freshnessslasourcesmonitoring

Interview question

What is dbt source freshness, and how do you configure it?

How to answer

The short answer

Source freshness checks whether raw source tables were updated recently enough. Not a row-level data test. Think of it as an on how stale landing data is allowed to be.

Configure in sources YAML

YAML
sources:
  - name: stripe
    database: raw
    schema: stripe
    freshness:
      warn_after: { count: 6, period: hour }
      error_after: { count: 12, period: hour }
    loaded_at_field: _loaded_at
    tables:
      - name: payments

dbt queries max(loaded_at_field) (or warehouse metadata when configured) and compares it to warn_after / error_after.

Run it

Shell
dbt source freshness
# often in CI / morning jobs before dbt build

Mental model

Why teams use it

  • Catch broken Fivetran/Airflow loads before transforming garbage or empty days
  • Separate "pipeline late" from "transform logic wrong"
  • Document expectations next to the source definition

Interview tip: "Freshness guards the EL boundary; schema tests guard the transform contracts. I fail the job on error_after for revenue-critical sources."