dbt expectations: Advanced Data Quality Testing
The dbt-expectations (opens in a new tab) package extends the core functionality of dbt by providing a comprehensive set of data quality tests. Inspired by the Great Expectations framework, these tests help you enforce data integrity and validate assumptions about your data.
What is dbt Expectations?
dbt-expectations
is a package designed to bring the power of Great Expectations-like data quality testing to your dbt models. It includes a variety of tests that allow you to verify the consistency, accuracy, and validity of your data.
How to Install dbt Expectations
To use dbt-expectations
in your dbt project, you need to add it as a dependency in your packages.yml
file and then install it using the dbt deps
command.
- Add to packages.yml:
- Install the package:
Commonly Used Tests and Examples
Here are some commonly used tests from the dbt-expectations package, along with examples of how to use them in your dbt models.
1. expect_table_row_count_to_be_between
This test checks if the number of rows in a table is within a specified range.
2. expect_table_row_count_to_equal_other_table
This test validates that the number of rows in one table matches the row count of another table.
3. expect_column_values_to_match_regex
This test checks if the values in a column match a specified regular expression pattern.
4. expect_column_values_to_match_regex_list
This test ensures that the values in a column match any of the regular expressions provided in a list.
5. expect_column_mean_to_be_between
This test checks if the mean (average) of the values in a column falls within a specified range.

Manage Sources and dbt Models in one place
Build end-to-end pipelines using a single framework.
Get Started