expect_column_pair_values_to_be_in_set
How it Works
The expect_column_pair_values_to_be_in_set test from the dbt-expectations package validates that for every row, the combination of values from two columns is a member of an explicitly defined set of allowed pairs. This is useful for enforcing business rules where certain column value combinations are valid while others are not.
Steps and Conditions
- Column Pair: Specify the two columns using
column_Aandcolumn_B. - Define Allowed Pairs: List the acceptable value combinations using
value_pairs_set. - Optional Row Condition: Filter rows using
row_condition. - Execution: Each row's column pair is checked against the allowed set.
- Outcome: Pass if all pairs are in the allowed set; fail if any invalid combination exists.
Example Usage: Product Configuration
A product configuration model should only allow specific combinations of product_tier and billing_cycle that the pricing team has approved.
models:
- name: product_configurations
tests:
- dbt_expectations.expect_column_pair_values_to_be_in_set:
column_A: product_tier
column_B: billing_cycle
value_pairs_set:
- ['starter', 'monthly']
- ['professional', 'monthly']
- ['professional', 'annual']
- ['enterprise', 'annual']This prevents invalid tier-billing combinations from entering the system, protecting pricing integrity.
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.