expect_table_column_count_to_equal_other_table
Feb 24, 2026
·
5
min read
Schema
·
dbt-expectations
·
Model,Seed,Source
How it Works
The expect_table_column_count_to_equal_other_table test from the dbt-expectations package validates that two tables have the same number of columns. This is useful for ensuring that a transformed model retains the same schema width as a source or reference table, guarding against silent column additions or removals.
Steps and Conditions
Comparison Model: Specify the reference model using
compare_model.Execution: The column counts of both tables are retrieved and compared.
Outcome: Pass if the counts are equal; fail if they differ.
Example Usage: Staging Layer
A data team wants to ensure their stg_products model always has the same number of columns as the raw raw_products source, detecting any columns inadvertently added or dropped during transformation.
Any schema divergence between staging and source is caught before it propagates to downstream models.





