-
Notifications
You must be signed in to change notification settings - Fork 178
Description
Describe the bug
When setting +materialized: materialized_view on a model simultaneously with +contract: { enforced: true }, I expected dbt to warn me if my documented column names/types got out of sync with my model SQL... or at least warn me if it's not supported!
I've had it set for a few weeks and just now realized that a model of mine was out of sync. 🙃 I then tested changing the materialization to table in dev and sure enough I got a contract failure.
I vaguely recall noticing that the docs say it's "Models materialized as table, view, and incremental ...", but I think at the time I internally thought that +materialized: materialized_view was essentially a sub-case of +materialized: view so didn't think my use case was excluded.
It seems easy enough to add this to the remaining materialization types for dbt-databricks.
Steps To Reproduce
Create a SQL model with the above configs, with a list of column names/types in my_model.yml which does not match the columns defined in my_model.sql. Call dbt run; it'll succeed with no warnings or errors.
Expected behavior
Either:
- something along the lines of
⚠️ [WARNING]: model contract unenforceable on models materialized as 'materialized_view' (models/model.sql), or - ❌
Compilation Error in model my_model (models/my_model.sql): Contracted models require data_type to be defined for each column. Please ensure that the column name and data_type are defined within the YAML configuration for the [...] column(s).
System information
The output of dbt --version:
$ dbt --version
WARNING:thrift.transport.sslcompat:using legacy validation callback
Core:
- installed: 1.10.13
- latest: 1.10.15 - Update available!
Your version of dbt-core is out of date!
You can find instructions for upgrading here:
https://docs.getdbt.com/docs/installation
Plugins:
- databricks: 1.10.14 - Update available!
- spark: 1.9.3 - Up to date!
At least one plugin is out of date with dbt-core.
You can find instructions for upgrading here:
https://docs.getdbt.com/docs/installation
The operating system you're using:
MacOS 15.7.1 (24G231)
The output of python --version:
Python 3.12.5
Additional context
I've (manually) explored the call graph a bit starting from a search in my project's folder (including inclusions from its venv):

From my spelunking it looks like dbt-databricks allows setting up constraints on materialized views -- but won't do the preflight "contract" check to for column names/types consistency.