How to Control the Cost of Running Data Tests in CI
Full-table tests on every PR burn warehouse credits; sampling and slim selection cut that cost sharply.
Limit CI to modified models, sample large sources with a CI-only filter, and auto-suspend the CI warehouse so idle time costs nothing.
Steps
- Restrict CI to
state:modified+so only changed models run. - Filter large sources to a recent window in the CI target only.
- Set the CI warehouse to auto-suspend quickly.
CI-only source limit
stg_events.sql
-- models/staging/stg_events.sql
select * from {{ source('raw', 'events') }}
{% if target.name == 'ci' %}
where event_date >= current_date - 7
{% endif %}Warehouse config
sql
-- run once against the CI warehouse
ALTER WAREHOUSE CI_WH SET
AUTO_SUSPEND = 60
AUTO_RESUME = TRUE
WAREHOUSE_SIZE = XSMALL;Gotchas
- A short auto-suspend means the CI warehouse only bills while a job actually runs.
- Sampling changes results; keep a nightly full run so quality is still verified end to end.
Related guides
How to Set Up dbt Slim CI With --defer and state:modifiedRun only the dbt models a PR changed by combining --select state:modified+ with --defer against a production…
How to Add a Data Diff Check in a Pull RequestShow how a dbt change alters output data in a pull request with recce or data-diff, comparing dev models agai…