accepted_values, severity, and source freshness
The problem
A status column is only supposed to be completed, pending, or returned. A source table is only supposed to have landed in the last few hours. Those are different assertions: one is about values, the other about recency. Official dbt documentation covers both, and mixing them into one “is this table fine?” test usually hides the thing that actually broke.
A working example
Values. The companion project declared:
- name: status
data_tests:
- accepted_values:
arguments:
values: ['completed', 'pending', 'returned']
dbt test with dbt-core 1.12.7 / dbt-duckdb 1.11.1: PASS. The seed only used those three statuses.
When a new status is legitimate, the test fails until you add it. That is usually correct. If the column is dirty and you are not ready to fail the job, official docs allow severity: warn (and warn_if / error_if thresholds) so the run can continue while still surfacing rows.
Recency. Official source freshness is not a generic data test on a model. You configure freshness on a source and run dbt source freshness, which compares a loaded-at timestamp to warn_after / error_after. A typical official shape:
# Official pattern (not executed in this project)
sources:
- name: jaffle
freshness:
warn_after: {count: 12, period: hour}
error_after: {count: 24, period: hour}
tables:
- name: orders
loaded_at_field: _loaded_at
data_tests:
- accepted_values:
arguments:
values: ['completed', 'pending', 'returned']
column_name: status
This project’s sources are seeds, which are not a useful freshness demonstration (they update when you dbt seed). Freshness was therefore not executed here; the YAML above is the official mechanism.
Volume / anomaly tests (row counts drifting vs history) are not built into those four generic tests. Tools such as Elementary add them. They were not installed or run for this site.
The gotcha
accepted_values is case-sensitive unless you explicitly normalize the column in a model first. A warehouse that stores Completed will fail a test for completed.
Freshness on the wrong timestamp — updated_at of a slowly changing dimension, or a column that is timezone-naive — produces false incidents. Official freshness uses the loaded_at_field you name; it will not guess.
Alert fatigue is real: official severity configs exist so not every failed assertion has to be error. A warn that nobody reads is still a failed feedback loop, just a quieter one.
When not to use this
- Do not put
accepted_valueson a column whose legal set changes daily (free-text notes, expanding event names) unless you generate the list from a controlled table. - Do not use freshness as a substitute for
not_nullon the business key. A table can be fresh and wrong. - Do not expect seed or infrequently batched tables to look “fresh” under a 12-hour window.
accepted_values on stg_orders.status passed in the companion project (dbt-core 1.12.7, dbt-duckdb 1.11.1). Freshness YAML and severity options are from official dbt documentation and were not executed here.