expect_column_distinct_count_to_equal
Feb 24, 2026
·
5
min read
Uniqueness
·
dbt-expectations
·
Column
How it Works
The expect_column_distinct_count_to_equal test from the dbt-expectations package validates that the number of distinct values in a column equals exactly a specified count. This is more precise than range-based cardinality checks and is ideal for columns with a fixed, known set of categories where the exact count is controlled.
Steps and Conditions
Column Selection: Identify the column to evaluate.
Set Expected Count: Provide the exact expected distinct count using
value.Execution: The distinct count is computed and compared to the expected value.
Outcome: Pass if the counts match; fail if they differ.
Example Usage: Fixed Taxonomy
A content platform uses a fixed taxonomy of exactly 10 content categories. The distinct count of the category column should always be exactly 10.
Any addition or removal of categories triggers the test failure, ensuring the taxonomy is managed through a controlled change process.





