Skip to content

Commit a1daff7

Browse files
authored
fix: warn on contract.enforced=true for materialized_view (#1421)
Resolves #1279 Upstream dbt does not support contracts on materialized views ([docs](https://docs.getdbt.com/docs/mesh/govern/model-contracts)). dbt-databricks was silently accepting `contract.enforced: true`, hiding yml/SQL drift. This PR emits a warning pointing at the dbt docs. Strictly additive; no existing build outcome changes. ### Checklist - [x] I have run this code in development and it appears to resolve the stated issue - [x] This PR includes tests, or tests are not required/relevant for this PR - [x] I have updated the `CHANGELOG.md`
1 parent 2636f11 commit a1daff7

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- Fix spurious `MicrobatchConcurrency` behavior-change warning firing on every run regardless of whether the project contained microbatch models ([#1406](https://github.com/databricks/dbt-databricks/issues/1406))
1212
- Stop emitting the `insert_overwrite will perform a dynamic insert overwrite` warning on every `insert_overwrite` run on SQL warehouses; warn instead only when `use_replace_on_for_insert_overwrite` is enabled but the cluster's DBR version does not support REPLACE ON ([#1305](https://github.com/databricks/dbt-databricks/issues/1305))
1313
- Fix DBR capability cache being permanently poisoned by a transient version-query failure ([#1398](https://github.com/databricks/dbt-databricks/issues/1398))
14+
- Warn when `contract.enforced: true` is set on a `materialized_view` model ([#1279](https://github.com/databricks/dbt-databricks/issues/1279))
1415

1516
## dbt-databricks 1.11.7 (Apr 17, 2026)
1617

dbt/include/databricks/macros/relations/materialized_view/create.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
{%- set model_columns = model.get('columns', {}) -%}
2525
{%- set contract_config = config.get('contract') -%}
2626
{%- if contract_config and contract_config.enforced -%}
27+
{%- do exceptions.warn(
28+
"contract.enforced=true on materialized_view '" ~ model.name ~ "': not supported by dbt (https://docs.getdbt.com/docs/mesh/govern/model-contracts). dbt-databricks provides best-effort support that may change without notice."
29+
) -%}
2730
{%- set model_constraints = model.get('constraints', []) -%}
2831
{%- else -%}
2932
{%- set model_constraints = [] -%}

0 commit comments

Comments
 (0)