expect_column_pair_values_to_be_equal

Feb 24, 2026

·

5

min read

Columns relationship

·

dbt-expectations

·

Model,Seed,Source

How it Works

The expect_column_pair_values_to_be_equal test from the dbt-expectations package verifies that for every row in a model, the value of one column equals the value of another. This is useful for validating denormalized copies of data, enforcing business rules where two fields must stay in sync, or detecting drift between calculated and stored values.

An optional row_condition can scope the check to relevant rows.

Steps and Conditions

  1. Column Pair: Specify the two columns to compare using column_A and column_B.

  2. Optional Row Condition: Filter rows before comparison.

  3. Execution: Each row's values for the two columns are compared.

  4. Outcome: Pass if all compared values are equal; fail if any differ.

Example Usage: Accounting System

An accounting system stores both a calculated_tax column and a posted_tax column. These should always be equal for finalized transactions.

models:
  - name: finalized_transactions
    tests:
      - dbt_expectations.expect_column_pair_values_to_be_equal:
          column_A: calculated_tax
          column_B: posted_tax
          row_condition: "status = 'finalized'"
models:
  - name: finalized_transactions
    tests:
      - dbt_expectations.expect_column_pair_values_to_be_equal:
          column_A: calculated_tax
          column_B: posted_tax
          row_condition: "status = 'finalized'"
models:
  - name: finalized_transactions
    tests:
      - dbt_expectations.expect_column_pair_values_to_be_equal:
          column_A: calculated_tax
          column_B: posted_tax
          row_condition: "status = 'finalized'"

Any discrepancy between calculated and posted tax values on finalized records will trigger the test to fail.

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.