expect_column_unique_value_count_to_be_between
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
- Column Selection: Identify the column to evaluate.
- Define Range: Set
min_valueand/ormax_value. - Execution: The distinct count is computed and compared to the range.
- 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: 50Fewer 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
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.