expect_table_row_count_to_be_between
How it Works
The expect_table_row_count_to_be_between test from the dbt-expectations package validates that the total number of rows in a model, seed, or source falls within a defined minimum and maximum. This is a fundamental volume check to catch unexpected data loss or explosive data growth that could indicate pipeline issues.
Optional group_by and row_condition arguments allow more targeted checks within data subsets.
Steps and Conditions
- Define Range: Set
min_valueand/ormax_valuefor acceptable row counts. - Optional Config: Apply
group_byandrow_conditionas needed. - Execution: The row count is computed and compared to the range.
- Outcome: Pass if the count is within range; fail if it falls outside.
Example Usage: E-commerce
An e-commerce platform loads daily orders and expects between 5,000 and 50,000 rows per day under normal operating conditions.
models:
- name: daily_orders
tests:
- dbt_expectations.expect_table_row_count_to_be_between:
min_value: 5000
max_value: 50000A row count outside this range flags either a data load failure or an abnormal spike in orders requiring investigation.
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.