MetricSign
EN|NLRequest Access
High severitydbt

Power BI Refresh Error:
dbt Model Contract Violation

What does this error mean?

A dbt model with an enforced contract failed because its output schema does not match the declared contract. The model's columns (names, data types, or count) differ from what is specified in the YAML contract definition.

Common causes

  • 1A column was added or removed from the model's SELECT statement but the contract YAML was not updated
  • 2The warehouse inferred a different data type for a column than what is declared in the contract (e.g., `bigint` vs `integer`)
  • 3A column alias in the model SQL does not exactly match the contract column name (case-sensitive mismatch)
  • 4The model was refactored and a column was renamed without updating the contract
  • 5A new column introduced by an upstream model change was not added to the contract

How to fix it

  1. 1Run `dbt compile --select <model>` to see the compiled SQL and compare output columns to the contract YAML.
  2. 2Update the contract YAML in the model's schema.yml to match the current model output — add any new columns and remove dropped ones.
  3. 3For data type mismatches, cast the column explicitly in the SQL to match the declared type: `CAST(col AS INTEGER) AS col`.
  4. 4Run `dbt build --select <model>` to re-validate the contract after updating the YAML.
  5. 5Consider using `dbt run --empty` to validate column structure without a full data load for large models.

Frequently asked questions

Should I update the contract or the model SQL when they diverge?

If the contract represents a published API consumed by other teams, update the SQL to match the contract. If the contract is internal documentation, update both the SQL and the contract together and notify downstream consumers.

Other dbt errors