expect_table_column_count_to_be_between
How it Works
The expect_table_column_count_to_be_between test from the dbt-expectations package verifies that the number of columns in a table falls within a minimum and maximum range. This is a lightweight schema guard that detects unintentional column additions or removals without requiring an exact column list.
Steps and Conditions
- Define Range: Set
min_valueand/ormax_valuefor the acceptable column count. - Execution: The actual column count is retrieved from schema metadata.
- Outcome: Pass if the count is within range; fail if it falls outside.
Example Usage: Data Lake
A data lake team processes semi-structured data where the column count is expected to stay between 10 and 30. Wild deviations suggest a schema explosion or collapse in the source.
models:
- name: raw_events
tests:
- dbt_expectations.expect_table_column_count_to_be_between:
min_value: 10
max_value: 30A column count outside this range triggers investigation into upstream schema changes.
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.