0
0
dbtdata~30 mins

Test severity levels in dbt - Mini Project: Build & Apply

Choose your learning style9 modes available
Test Severity Levels in dbt
📖 Scenario: You are working on a data project using dbt. You want to ensure your data quality by adding tests with different severity levels. This helps you decide which test failures should stop your workflow and which should just warn you.
🎯 Goal: Learn how to add tests in dbt with different severity levels: error and warn. You will create a simple model, add tests, and configure their severity.
📋 What You'll Learn
Create a dbt model with sample data
Add a test with severity level error
Add a test with severity level warn
Run dbt tests and observe output
💡 Why This Matters
🌍 Real World
Data teams use dbt tests with severity levels to catch critical data issues early and allow less critical warnings to be reviewed later.
💼 Career
Understanding test severity in dbt helps data analysts and engineers maintain data quality and reliability in production pipelines.
Progress0 / 4 steps
1
Create a simple dbt model
Create a dbt model file named models/customers.sql with the following SQL code:
select 1 as id, 'Alice' as name union all select 2, 'Bob'
dbt
Need a hint?
Make sure the file is named exactly customers.sql inside the models folder and contains the exact SQL query.
2
Add a test with severity level error
In the tests folder, create a test file named not_null_id.yml with this content:
version: 2
models:
- name: customers
tests:
- not_null:
column_name: id
severity: error
dbt
Need a hint?
The test file must be YAML format with version 2 and specify severity: error for the not_null test on id column.
3
Add a test with severity level warn
Add another test in the same tests/not_null_id.yml file for the name column with severity set to warn. The YAML should look like this:
version: 2
models:
- name: customers
tests:
- not_null:
column_name: id
severity: error
- not_null:
column_name: name
severity: warn
dbt
Need a hint?
Add the second not_null test for the name column with severity set to warn under the same model.
4
Run dbt tests and observe severity output
Run dbt test in your terminal to execute the tests. Observe that if the id column test fails, dbt stops with an error. If the name column test fails, dbt shows a warning but continues.
dbt
Need a hint?
Use the terminal to run 'dbt test' and watch the output for error and warning messages.