dbt Tests

expect_column_unique_value_count_to_be_between

dbt-expectations

·

Column

·

Uniqueness

How it Works

The expect_column_unique_value_count_to_be_between test from the dbt-expectations package checks that the count of distinct values in a column falls within a specified minimum and maximum. This is a softer version of exact distinct count checks and is well-suited for columns whose cardinality is expected to grow over time but within predictable bounds.

Steps and Conditions

  1. Column Selection: Identify the column to evaluate.

  2. Define Range: Set min_value and/or max_value.

  3. Execution: The distinct count is computed and compared to the range.

  4. Outcome: Pass if the count is within range; fail otherwise.

Example Usage: Platform Analytics

A platform analytics team expects their active_experiment column to contain between 5 and 50 distinct experiment IDs at any given time.

models:
  - name: user_experiments
    columns:
      - name: experiment_id
        tests:
          - dbt_expectations.expect_column_unique_value_count_to_be_between:
              min_value: 5
              max_value: 50
models:
  - name: user_experiments
    columns:
      - name: experiment_id
        tests:
          - dbt_expectations.expect_column_unique_value_count_to_be_between:
              min_value: 5
              max_value: 50
models:
  - name: user_experiments
    columns:
      - name: experiment_id
        tests:
          - dbt_expectations.expect_column_unique_value_count_to_be_between:
              min_value: 5
              max_value: 50

Fewer than 5 distinct experiments suggests experiments are being dropped; more than 50 could indicate runaway experiment proliferation.

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

Stop Managing Pipelines. Start Shipping Them.

Join the teams that replaced manual dbt™ workflows with agentic AI. Free to start, no credit card required.

Stop Managing Pipelines. Start Shipping Them.

Join the teams that replaced manual dbt™ workflows with agentic AI. Free to start, no credit card required.

Stop Managing Pipelines. Start Shipping Them.

Join the teams that replaced manual dbt™ workflows with agentic AI. Free to start, no credit card required.

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.