expect_column_pair_values_a_to_be_greater_than_b
Feb 24, 2026
·
5
min read
Columns relationship
·
dbt-expectations
·
Model,Seed,Source
How it Works
The expect_column_pair_values_a_to_be_greater_than_b test from the dbt-expectations package validates that for every row, the value of one column is greater than the value of another column. The or_equal argument (default false) controls whether equal values are also acceptable.
This is ideal for enforcing business rules like end dates being after start dates, or maximum values exceeding minimums.
Steps and Conditions
Define Column Pair: Specify
column_A(the greater column) andcolumn_B(the lesser column).Or Equal: Set
or_equal: trueifcolumn_A >= column_Bis acceptable.Optional Row Condition: Filter rows using
row_condition.Execution: Each row is evaluated for the A > B (or A >= B) condition.
Outcome: Pass if all rows satisfy the condition; fail if any violate it.
Example Usage: Event Scheduling
An event scheduling platform stores event start and end times. The end time must always be after the start time.
Any event where the end time precedes the start time is flagged, preventing corrupted event records from reaching the calendar application.





