High severityconfiguration
Power BI Refresh Error:
ColumnTypeMismatch
What does this error mean?
dbt's model contract enforcement found that a column's actual data type in the warehouse does not match the declared type in the model's YAML contract. This error enforces strict schema governance — models with contracts must produce exactly the declared columns and types or the run fails.
Common causes
- 1A model's SQL was changed to cast a column differently than the declared contract type (e.g., the contract says `bigint` but the column is now `varchar`)
- 2The upstream source changed the type of a column that is passed through to the contracted model without an explicit CAST
- 3Different warehouses represent the same logical type differently (e.g., `int` vs `integer` vs `int4`) causing false mismatches
- 4A dbt version upgrade changed how adapter type names are normalised in contract checks
- 5The contract was defined with a warehouse-specific type alias that is not recognised by the current adapter plugin
How to fix it
- 1Run `dbt run --select <model>` and check the error output — it will name the column and show the expected vs actual type.
- 2Add an explicit CAST in the model SQL to coerce the column to the declared contract type: `CAST(<column> AS <declared_type>) AS <column_name>`.
- 3Review the contract definition in the model's YAML and ensure the declared `data_type` matches the canonical type name for your adapter.
- 4If the type difference is nominal (e.g., `int` vs `integer`), use the full canonical type name that the adapter uses in its type mapping.
- 5Run `dbt debug --connection` and inspect the adapter's type map to find the correct canonical type name for your warehouse.