dbt-expectations helps you check if your data is correct and clean. It makes sure your data follows rules you set.
dbt-expectations for data quality
tests:
- dbt_expectations.expect_column_values_to_not_be_null:
column: your_column_name
- dbt_expectations.expect_column_values_to_be_between:
column: your_column_name
min_value: 0
max_value: 100
- dbt_expectations.expect_column_values_to_be_unique:
column: your_column_nameEach test is written under the tests section in your dbt model or schema file.
You specify the test name and the column it applies to, plus any extra parameters like min or max values.
user_id column has no missing values.tests:
- dbt_expectations.expect_column_values_to_not_be_null:
column: user_idage column values are between 0 and 120.tests:
- dbt_expectations.expect_column_values_to_be_between:
column: age
min_value: 0
max_value: 120email column are unique.tests:
- dbt_expectations.expect_column_values_to_be_unique:
column: emailThis example shows a dbt schema file defining tests for the customers model. It checks that customer_id is never null and unique, and age is between 0 and 120.
version: 2 models: - name: customers columns: - name: customer_id tests: - dbt_expectations.expect_column_values_to_not_be_null - dbt_expectations.expect_column_values_to_be_unique - name: age tests: - dbt_expectations.expect_column_values_to_be_between: min_value: 0 max_value: 120
dbt-expectations is built on top of Great Expectations, so it uses similar test ideas but fits into dbt workflows.
You can add many types of tests like checking patterns, value sets, or statistical properties.
Running these tests regularly helps catch data problems early.
dbt-expectations lets you write simple tests to check your data quality.
You add tests in your dbt schema files under the tests section.
Common tests check for nulls, uniqueness, value ranges, and patterns.