# dbt tests passed but the table didn't load: add source freshness and volume checks

> unique and not_null still pass when yesterday's rows are sitting there. Freshness and a row-count test catch a load that never arrived, or arrived short.

Source: https://rowmonitor.com/guides/dbt-tests-pass-table-not-loaded · Updated 2026-11-19

Column tests like `unique` and `not_null` check the rows that are in the table. If last night's load never ran, yesterday's rows are still unique and still not null, so every test passes. To catch a table that didn't load, or loaded only part of its data, add two more checks: **freshness** (did new data arrive?) and **volume** (did enough of it arrive?).

## Why green tests miss a missing load

- A data test is a query that returns failing rows. Old rows have no failures, so the test passes.
- `dbt build` runs models, tests, seeds, snapshots, and user-defined functions (functions from dbt 1.11). It does not run freshness checks. That is a separate command.
- If the whole dbt job doesn't run (scheduler down, job paused, upstream DAG stuck), none of its tests run either, so nothing turns red.

## 1. Freshness: configure and run dbt source freshness

Declare how old the newest row can be. Since dbt 1.9, `freshness` goes under `config:`. Since dbt 1.10, `loaded_at_field` does too. dbt Core 1.x uses `dbt source freshness`. `dbt freshness` is the v2.0 command, and it checks sources and models.

```yaml
# models/sources.yml
sources:
  - name: shop
    database: raw
    config:
      freshness:
        warn_after: {count: 12, period: hour}
        error_after: {count: 24, period: hour}
      loaded_at_field: _loaded_at
    tables:
      - name: orders
        config:
          freshness:
            warn_after: {count: 6, period: hour}
            error_after: {count: 12, period: hour}
      - name: country_codes
        config:
          freshness: null   # static table, don't check
```

Run it on a schedule, separately from (or before) your build:

```shell
dbt source freshness                      # dbt Core 1.x
dbt source freshness --select "source:shop.orders"
dbt freshness                             # dbt v2.0: sources and models
```

- `warn_after` and `error_after` each need both `count` and `period`. Set neither and dbt does not check that resource. Setting only one of `count` or `period` warns at parse time and errors when `dbt freshness` runs.
- No `loaded_at_field`? On adapters that expose table metadata, dbt uses the warehouse's last-modified time when it can. Views and external models need `loaded_at_field` or `loaded_at_query`, because they have no row-level metadata. An empty `loaded_at_field` is treated as unset.
- `loaded_at_query` (1.10+) is the SQL that returns the newest timestamp, for example to ignore tiny trickle loads. Setting both `loaded_at_query` and `loaded_at_field` on the same resource is a parse error. `filter` does not apply to `loaded_at_query`.
- `filter` adds a `WHERE` clause so the freshness query scans less of a big table. It does not change other uses of that source or model.
- `freshness: null` on a table skips the check. Use it for a static table such as country codes.
- `dbt source freshness` writes `target/sources.json`. `dbt freshness` (v2.0) writes `target/freshness.json` for the sources and models it checked, and also writes `target/sources.json` when the run includes sources.

## 2. Freshness on models: dbt_utils.recency

For a model built by dbt (not a source), the dbt-utils `recency` test fails when the newest timestamp is older than the interval. The test below fails when `created_at` is more than 26 hours old.

```yaml
models:
  - name: fct_orders
    data_tests:
      - dbt_utils.recency:
          arguments:
            datepart: hour
            field: created_at
            interval: 26
```

Put those keys under `arguments:` on dbt Core 1.10.5 and higher. The [dbt data tests docs](https://docs.getdbt.com/reference/resource-properties/data-tests) show that shape, and the [dbt-utils README](https://github.com/dbt-labs/dbt-utils/blob/main/README.md) recommends it for Core 1.10.6 and higher. Fusion requires `arguments:`. On older Core, drop `arguments:` and put `datepart`, `field`, and `interval` directly under the test name. `data_tests` is the property name. `tests` is the older alias.

## 3. Volume: compare yesterday with the same weekday

A load that brings in a third of the usual rows passes every column test and every freshness check. Add a singular test that compares yesterday's count with the same weekday over the last four weeks. A returned row fails the test. The threshold is strict: yesterday fails when it is under 70% of that average, which is a drop of more than 30%.

```sql
-- tests/assert_fct_orders_volume.sql
with daily as (
  select cast(created_at as date) as order_date, count(*) as row_count
  from {{ ref('fct_orders') }}
  where created_at >= current_date - 29
  group by 1
),
yesterday as (
  select coalesce(sum(row_count), 0) as row_count
  from daily
  where order_date = current_date - 1
),
baseline as (
  select avg(row_count) as avg_row_count
  from daily
  where order_date in (current_date - 8, current_date - 15, current_date - 22, current_date - 29)
)
select y.row_count, b.avg_row_count
from yesterday y cross join baseline b
where y.row_count < 0.7 * b.avg_row_count
```

This statement was run on Postgres 17.12 with `{{ ref('fct_orders') }}` replaced by a table, session time zone UTC. `cast(created_at as date)` uses that session time zone. A day of 37 rows against a baseline of 100 returned one row (37 and 100). A missing yesterday returned one row (0 and 100). A normal day of 100 against 100 returned no rows, so the test passed. 70 against 100 also returned no rows. 69 against 100 returned one row. With no baseline days yet, the average is null, the comparison is unknown, and the test returns no rows, so it does not fire on a brand-new table.

The same statement was not run on Snowflake. Snowflake documents `CURRENT_DATE` minus an integer as date arithmetic, `CAST` of a timestamp to `DATE`, and coercion of `DATE` to `TIMESTAMP`. That is what the docs say. It is not a run on Snowflake.

BigQuery was not run either. Swapping `current_date - n` for `date_sub(current_date(), interval n day)` still leaves a `DATE`, and BigQuery does not compare a `TIMESTAMP` to a `DATE`. `DATE(timestamp)` extracts the date, and `DATE_SUB` subtracts days from a date. `date - integer` is valid BigQuery arithmetic only when the value is already a date. Use this variant, which follows those docs and was not executed:

```sql
-- tests/assert_fct_orders_volume_bigquery.sql
-- Checked against BigQuery date-function docs. Not executed.
with daily as (
  select date(created_at) as order_date, count(*) as row_count
  from {{ ref('fct_orders') }}
  where date(created_at) >= date_sub(current_date(), interval 29 day)
  group by 1
),
yesterday as (
  select coalesce(sum(row_count), 0) as row_count
  from daily
  where order_date = date_sub(current_date(), interval 1 day)
),
baseline as (
  select avg(row_count) as avg_row_count
  from daily
  where order_date in (
    date_sub(current_date(), interval 8 day),
    date_sub(current_date(), interval 15 day),
    date_sub(current_date(), interval 22 day),
    date_sub(current_date(), interval 29 day)
  )
)
select y.row_count, b.avg_row_count
from yesterday y cross join baseline b
where y.row_count < 0.7 * b.avg_row_count
```

If you have a trusted upstream count, `dbt_utils.equal_rowcount` fails when the two relations have different numbers of rows. `dbt_utils.fewer_rows_than` fails unless this model has fewer rows than the relation you name. Both take `compare_model` under `arguments:`, the same way `recency` does.

## 4. Check from outside the dbt job

Freshness and volume tests that live inside the dbt job only run when the job runs. If the scheduler is down, nothing reports. Run `dbt source freshness` as its own scheduled step, or use a monitor that queries the warehouse on its own schedule. [rowmonitor-runcheck](https://github.com/kharipara/rowmonitor-runcheck) is a free, open-source script with no account. It can read a dbt Core `run_results.json` and post to a Slack incoming webhook or a generic webhook. It does not read dbt Cloud, it does not keep history, and it does not check tables. Install from PyPI: pip install rowmonitor-runcheck. Commands and hosted Row Monitor are on the [Airflow page](https://rowmonitor.com/airflow#runcheck).

## Where Row Monitor fits

Row Monitor connects to Postgres, BigQuery, or Snowflake and runs schema, volume, and freshness checks outside the dbt job, then alerts in email or Slack. Scheduled table checks run once a day on every plan, and you can run a check from the monitor. Airflow checks are separate and run about every 15 minutes. The default row-count threshold is 30%. A change of 30% or more alerts, and you can set the band from 1% to 100%.

On BigQuery, freshness is the table's last-modified metadata. On Snowflake, it is `LAST_ALTERED`. On Postgres, it is the latest value of a timestamp column you choose, or one it detects. You can turn freshness off for a table that has no reliable timestamp. Schema and row-count checks still run. Each anomaly includes a plain-English explanation and a dbt `schema.yml` snippet you can paste into the project. Tables with no timestamp column are covered in [freshness without a timestamp column](https://rowmonitor.com/guides/freshness-without-timestamp-column).

Prices are in US dollars. Free is US$0 a month for 3 tables, Pro is US$39 a month for 50 tables, and Team is US$99 a month for 500 tables. The Airflow plugin is included in every plan. It is not a paid add-on. Row Monitor does not replace dbt tests. Keep `unique`, `not_null`, and the rest for row-level rules, and use an outside check for the load that never arrived.

## A check that runs when the dbt job doesn't

Row Monitor checks schema, volume, and freshness on the tables you name, once a day, and you can run a check from the monitor. Airflow checks run about every 15 minutes. The default row-count band is 30%, adjustable from 1% to 100%. Free is US$0 for 3 tables.

[Start free](https://rowmonitor.com/signup)

## FAQ

### Does dbt build run source freshness?

No. dbt build runs models, tests, seeds, snapshots, and user-defined functions from dbt 1.11. It does not run freshness. Run dbt source freshness on dbt Core 1.x, or dbt freshness on dbt v2.0, as a separate step.

### Do I need a loaded_at_field?

Not always. Where the adapter exposes table metadata, dbt can use the warehouse's last-modified time. Views and external models need loaded_at_field or loaded_at_query. On BigQuery, metadata freshness is not reliable for wildcard sources such as events_*. The flag bigquery_reject_wildcard_metadata_source_freshness makes dbt raise an error in that case. Set loaded_at_field to check those tables with a query.

### What's the difference between dbt source freshness and dbt freshness?

dbt source freshness checks sources only and is the command in dbt Core 1.x. It writes target/sources.json. dbt freshness is the dbt v2.0 command. It checks sources and models, writes target/freshness.json, and also writes target/sources.json when the run includes sources. The older command stays for compatibility.

### How do I test row counts in dbt?

Write a singular test that compares yesterday's count with the same weekday over the last four weeks, and fail when it is under 70% of that average. Or use dbt_utils.equal_rowcount when two relations should match, and dbt_utils.fewer_rows_than when this model should have fewer rows than another relation.

### Why compare with the same weekday?

Many tables load less on weekends. Comparing Monday with recent Mondays avoids false alarms that a plain yesterday-versus-the-day-before check gives.
