0
0
dbtdata~10 mins

Test severity levels in dbt - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Test severity levels
Define test in dbt
Assign severity level
Run dbt tests
Test result: Pass or Fail
If Fail -> Check severity
Fail build
Report results
This flow shows how dbt tests are defined with severity levels, run, and how failures are handled differently based on severity.
Execution Sample
dbt
version: 2
models:
  - name: customers
    tests:
      - unique:
          column_name: id
        config:
          severity: error
      - not_null:
          column_name: id
        config:
          severity: warn
Defines two tests on the customers model with different severity levels: error and warn.
Execution Table
StepTest NameSeverityTest ResultAction TakenBuild Status
1uniqueerrorpassNo actioncontinue
2not_nullwarnfailLog warningcontinue
3uniqueerrorfailFail buildstop
4not_nullwarnpassNo actionstop
5uniqueerrorpassNo actionstop
6not_nullwarnfailLog warningstop
💡 Build stops immediately if any test with severity 'error' fails; warnings do not stop the build.
Variable Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 4After Step 5After Step 6
Build Statuscontinuecontinuecontinuestopstopstopstop
Warnings Logged0011112
Key Moments - 2 Insights
Why does the build stop at step 3 but not at step 2 even though both tests fail?
Because step 3 fails a test with severity 'error' which stops the build immediately, while step 2 fails a 'warn' severity test that only logs a warning and continues. See execution_table rows 2 and 3.
What happens if multiple warn severity tests fail?
All warn failures log warnings but do not stop the build. The build continues running all tests. See execution_table rows 2 and 6 and variable_tracker for warnings count.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the build status after step 2?
Astop
Bcontinue
Cpaused
Dunknown
💡 Hint
Check the 'Build Status' column at step 2 in the execution_table.
At which step does the build stop due to a test failure?
AStep 3
BStep 2
CStep 6
DStep 1
💡 Hint
Look for the first 'stop' in the 'Build Status' column in the execution_table.
If the severity of the unique test was changed from 'error' to 'warn', what would happen at step 3?
ABuild would stop
BTest would pass automatically
CBuild would continue with a warning
DTest would be skipped
💡 Hint
Refer to how 'warn' severity tests behave in the execution_table and key_moments.
Concept Snapshot
dbt test severity levels:
- severity: error stops the build on failure
- severity: warn logs a warning but continues
- define severity in test config
- errors are critical, warnings are advisory
- build status depends on test severity results
Full Transcript
In dbt, tests can have severity levels like 'error' or 'warn'. When tests run, if an 'error' severity test fails, the build stops immediately. If a 'warn' severity test fails, it logs a warning but the build continues. This allows teams to prioritize critical issues while still being aware of less critical ones. The execution table shows test results step-by-step, tracking build status and warnings logged. Understanding severity helps manage test failures effectively.