expect_table_column_count_to_equal

Feb 23, 2026dbt-expectations · Model,Seed,Source · Schema

How it Works

The expect_table_column_count_to_equal test from the dbt-expectations package validates that a table has exactly the number of columns specified. This is a stricter variant of expect_table_column_count_to_be_between and is suitable for tables with a tightly defined, fixed schema.

Steps and Conditions

  1. Set Expected Count: Provide the exact column count using value.
  2. Execution: The actual column count is retrieved from schema metadata and compared.
  3. Outcome: Pass if the counts match exactly; fail if they differ.

Example Usage: Contract-Bound Data

A data team exports a contract_data model to a partner via API. The contract specifies exactly 12 fields. Any schema change that adds or removes a column must be flagged.

models:
  - name: contract_data
    tests:
      - dbt_expectations.expect_table_column_count_to_equal:
          value: 12

Any deviation from 12 columns will fail the test and prevent a breaking schema change from being deployed to the partner API.

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.