store_failures
▶Changelog
The configured test(s) will store their failures when dbt test --store-failures
is invoked.
Description
Optionally set a test to always or never store its failures in the database.
- If specified as
true
orfalse
, thestore_failures
config will take precedence over the presence or absence of the--store-failures
flag. - If the
store_failures
config isnone
or omitted, the resource will use the value of the--store-failures
flag. - When true,
store_failures
save all the record(s) that failed the test only if limit is not set or if there are fewer records than the limit.store_failures
are saved in a new table with the name of the test. By default,store_failures
use a schema nameddbt_test__audit
, but, you can configure the schema to a different value.
This logic is encoded in the should_store_failures()
macro.
- Specific test
- Singular test
- Generic test block
- Project level
Configure a specific instance of a generic (schema) test:
models/<filename>.yml
version: 2
models:
- name: my_model
columns:
- name: my_column
tests:
- unique:
config:
store_failures: true # always store failures
- not_null:
config:
store_failures: false # never store failures
Configure a singular (data) test:
tests/<filename>.sql
{{ config(store_failures = true) }}
select ...
Set the default for all instances of a generic (schema) test, by setting the config inside its test block (definition):
macros/<filename>.sql
{% test <testname>(model, column_name) %}
{{ config(store_failures = false) }}
select ...
{% endtest %}
Set the default for all tests in a package or project:
dbt_project.yml
tests:
+store_failures: true # all tests
<package_name>:
+store_failures: false # tests in <package_name>
0