expect_column_distinct_count_to_equal

Feb 23, 2026dbt-expectations · Column · Uniqueness

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

  1. Column Selection: Identify the column to evaluate.
  2. Set Expected Count: Provide the exact expected distinct count using value.
  3. Execution: The distinct count is computed and compared to the expected value.
  4. 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.

models:
  - name: content_items
    columns:
      - name: category
        tests:
          - dbt_expectations.expect_column_distinct_count_to_equal:
              value: 10

Any addition or removal of categories triggers the test failure, ensuring the taxonomy is managed through a controlled change process.

Interested to Learn More? Try Out the Free 14-Days Trial

One AI-native workspace to build, ship, and monitor dbt™ — without the tool sprawl.

Join industry leaders winning with DinoAI agents

Data engineers and analysts at the most AI-native startups and enterprises use Paradime's DinoAI agents everyday to become market leaders.