expect_table_row_count_to_equal
How it Works
The expect_table_row_count_to_equal test from the dbt-expectations package asserts that a model, seed, or source contains exactly a specified number of rows. This is most commonly used with seed files or reference tables whose row count is known and fixed, such as lookup tables or currency lists.
Steps and Conditions
- Set Expected Count: Provide the exact expected row count using
value. - Optional Group By: Apply
group_byto check counts within subgroups. - Execution: The actual row count is computed and compared to the expected value.
- Outcome: Pass if counts match exactly; fail if they differ.
Example Usage: Reference Data
A data team maintains a currency_codes seed file that should always contain exactly 180 rows (one per ISO currency).
seeds:
- name: currency_codes
tests:
- dbt_expectations.expect_table_row_count_to_equal:
value: 180Any accidental addition or deletion of rows in the seed file will be caught before deployment.
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.