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

  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
models:
  - name: content_items
    columns:
      - name: category
        tests:
          - dbt_expectations.expect_column_distinct_count_to_equal:
              value: 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

More Articles

decorative icon

Experience Analytics for the AI-Era

Start your 14-day trial today - it's free and no credit card needed

decorative icon

Experience Analytics for the AI-Era

Start your 14-day trial today - it's free and no credit card needed

decorative icon

Experience Analytics for the AI-Era

Start your 14-day trial today - it's free and no credit card needed

Copyright © 2026 Paradime Labs, Inc.

Made with ❤️ in San Francisco ・ London

*dbt® and dbt Core® are federally registered trademarks of dbt Labs, Inc. in the United States and various jurisdictions around the world. Paradime is not a partner of dbt Labs. All rights therein are reserved to dbt Labs. Paradime is not a product or service of or endorsed by dbt Labs, Inc.

Copyright © 2026 Paradime Labs, Inc.

Made with ❤️ in San Francisco ・ London

*dbt® and dbt Core® are federally registered trademarks of dbt Labs, Inc. in the United States and various jurisdictions around the world. Paradime is not a partner of dbt Labs. All rights therein are reserved to dbt Labs. Paradime is not a product or service of or endorsed by dbt Labs, Inc.

Copyright © 2026 Paradime Labs, Inc.

Made with ❤️ in San Francisco ・ London

*dbt® and dbt Core® are federally registered trademarks of dbt Labs, Inc. in the United States and various jurisdictions around the world. Paradime is not a partner of dbt Labs. All rights therein are reserved to dbt Labs. Paradime is not a product or service of or endorsed by dbt Labs, Inc.