Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing
Back
  1. Home
  2. Interview prep
  3. Source freshness

dbt · Testing & Documentation

Source freshness

Mediumdbt-16
source freshnessslasourcesmonitoring

Question

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

Solution

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

Configure in sources 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

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

Mental model

EL job should land rows with _loaded_at ≈ now
        |
        v
dbt source freshness checks max(_loaded_at)
        |
   ok / warn / error vs SLA windows

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."

PreviousNext