Batch tests
The --batch-tests flag combines compatible data tests that target the same model into a single query per test type, rather than running one query per test. This reduces the number of queries dbt runs for tests, which can improve performance in projects with many data tests.
Batching tests
Batching applies to dbt build and dbt test. dbt batches a group of tests when all of these are true:
- The tests are
uniqueornot_null - They're attached to the same model
- They use their default configuration
- At least two of them are the same type
dbt excludes tests from batching when any of the following is set:
severityerror_ifwarn_iffail_calclimitwherestore_failuresstore_failures_as
Excluded tests run on their own, as they do without batching.
Setting the flag
dbt resolves batch_tests from three places, in order of precedence:
- The
--batch-testscommand-line flag - The
DBT_ENGINE_BATCH_TESTSenvironment variable - The
flagsblock in your root project'sdbt_project.yml
For example, on the command line:
CLI
dbt build --batch-tests
With an environment variable:
Env var
export DBT_ENGINE_BATCH_TESTS=true
dbt build
In your dbt_project.yml:
dbt_project.yml
flags:
batch_tests: true
Was this page helpful?
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
0