equality
How it Works
The equality test from dbt-utils™ validates that two models contain exactly the same rows and columns. It performs a symmetric difference check — rows present in one model but not the other are reported as failures. This is commonly used to validate that a refactored model produces identical output to the original, or to confirm that two independently derived pipelines agree.
An optional compare_columns argument allows limiting the comparison to a specific subset of columns.
Steps and Conditions
- Comparison Model: Specify the reference model using
compare_model. - Optional Column Subset: Use
compare_columnsto compare only selected columns. - Execution: A symmetric difference is computed between the two models.
- Outcome: Pass if both models contain identical rows for the compared columns; fail if any discrepancies exist.
Example Usage: Model Refactoring
A data engineer is refactoring the revenue model and wants to confirm the new version produces identical output to the old one before deprecating it.
models:
- name: revenue_v2
tests:
- dbt_utils.equality:
compare_model: ref('revenue_v1')
compare_columns: ['date', 'product_id', 'revenue_usd']Any row-level difference between revenue_v2 and revenue_v1 surfaces a failure, providing confidence before the old model is retired.
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.