Test severity levels help decide how serious a test failure is. This guides what action to take when a test fails.
Test severity levels in dbt
Start learning this pattern below
Jump into concepts and practice - no test required
tests:
- unique:
severity: error
- not_null:
severity: warnThe severity field can be set to error or warn.
error means the test failure is serious and should stop the process.
warn means the failure is less serious and should only warn.
tests:
- unique:
severity: errortests:
- not_null:
severity: warntests:
- accepted_values:
values: ['active', 'inactive']
severity: errorThis dbt schema file defines tests on the customers model. The customer_id column must be unique (error if fails) and not null (warn if fails). The status column must have accepted values, failing with error severity.
version: 2 models: - name: customers columns: - name: customer_id tests: - unique: severity: error - not_null: severity: warn - name: status tests: - accepted_values: values: ['active', 'inactive'] severity: error
Severity levels help control your data quality workflow.
Use error for tests that must pass to trust your data.
Use warn for tests that highlight issues but don't block processes.
Test severity levels tell dbt how serious a test failure is.
error stops the process; warn only warns.
Use severity to manage data quality and workflow priorities.
Practice
ERROR do?Solution
Step 1: Understand dbt test severity levels
dbt uses severity levels to decide what happens when a test fails.Step 2: Identify the effect of ERROR severity
When severity is set to ERROR, dbt stops the run immediately on failure.Final Answer:
It stops the dbt run if the test fails. -> Option AQuick Check:
ERROR severity = stops run [OK]
- Confusing ERROR with WARN severity
- Thinking ERROR retries the test
- Assuming ERROR ignores failures
Solution
Step 1: Recall YAML syntax for dbt test severity
dbt expects severity as a key-value pair with uppercase values like WARN or ERROR.Step 2: Identify correct syntax
The correct syntax uses a colon and uppercase WARN:severity: WARN.Final Answer:
severity: WARN -> Option CQuick Check:
YAML key-value with uppercase WARN = correct [OK]
- Using lowercase 'warn' instead of uppercase
- Using equals sign instead of colon
- Spelling severity value incorrectly
tests:
- unique:
column_name: id
severity: WARNWhat happens if the test fails during a dbt run?
Solution
Step 1: Analyze the severity level in the test config
The severity is set to WARN, which means dbt should warn but not stop.Step 2: Understand dbt behavior on WARN severity
When a test fails with WARN severity, dbt logs a warning and continues the run.Final Answer:
The failure is logged as a warning, but the run continues. -> Option AQuick Check:
WARN severity = warn and continue [OK]
- Thinking WARN stops the run
- Assuming WARN ignores failures
- Believing tests retry automatically
tests:
- not_null:
column_name: user_id
severity: ERRORBut your dbt run does not stop when the test fails. What is the likely problem?
Solution
Step 1: Check correct placement of severity in dbt tests
Severity must be set inside theconfigblock, not directly under the test.Step 2: Identify why run does not stop
Since severity is misplaced, dbt ignores it and uses default behavior, so run does not stop.Final Answer:
The severity key is misplaced; it should be under 'config'. -> Option BQuick Check:
Severity must be inside config = The severity key is misplaced; it should be under 'config'. [OK]
- Using lowercase severity value
- Misplacing severity outside config
- Assuming test name is wrong
email column?Solution
Step 1: Recall correct severity placement in dbt YAML
Severity must be inside aconfigblock under each test.Step 2: Match severities to tests as required
Setnot_nullseverity to WARN anduniqueseverity to ERROR inside their config blocks.Final Answer:
Tests with severity inside config: not_null WARN, unique ERROR. -> Option DQuick Check:
Severity inside config with correct WARN/ERROR = tests: - not_null: column_name: email config: severity: WARN - unique: column_name: email config: severity: ERROR [OK]
- Placing severity outside config block
- Swapping WARN and ERROR severities
- Using lowercase severity values
