equal_rowcount

Feb 24, 2026

·

5

min read

Volume, Tables relationship

·

dbt-utils

·

Model

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

  1. Dataset Selection: Identify the model to test and the comparison model (compare_model).

  2. Row Count Comparison: Both models are counted and compared.

  3. 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.

models:
  - name: stg_pos_events
    tests:
      - dbt_utils.equal_rowcount:
          compare_model: ref('raw_pos_events'

models:
  - name: stg_pos_events
    tests:
      - dbt_utils.equal_rowcount:
          compare_model: ref('raw_pos_events'

models:
  - name: stg_pos_events
    tests:
      - dbt_utils.equal_rowcount:
          compare_model: ref('raw_pos_events'

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.

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.