How it Works
The equal_rowcount test from dbt-utils™ ensures that two models contain exactly the same number of rows. It's a straightforward but powerful check for validating that no records are inadvertently dropped or duplicated during a transformation step. This test is commonly used to compare a staging model against its raw source, or to verify that a join-based model preserves row counts correctly.
Steps and Conditions
Dataset Selection: Identify the model to test and the comparison model (
compare_model).Row Count Comparison: Both models are counted and compared.
Outcome: Pass if counts are equal; fail if they differ.
Example Usage: Retail Data Pipeline
A retail company loads point-of-sale events into a raw table and then transforms them into a cleaned staging layer. They want to confirm no events are lost during transformation.
If stg_pos_events has fewer or more rows than raw_pos_events, the test fails and alerts the team to investigate the transformation logic.





