From 5b7bae6c3d4816a09b502aabd42d12bd0a191341 Mon Sep 17 00:00:00 2001 From: Shubham Dhal Date: Thu, 23 Apr 2026 17:29:46 +0530 Subject: [PATCH 1/2] fix: warn on contract.enforced=true for materialized_view (#1279) Upstream dbt does not support contracts on materialized views (https://docs.getdbt.com/docs/mesh/govern/model-contracts). dbt-databricks was silently accepting the flag, hiding yml/SQL drift. Now emits a warning pointing at the dbt docs. Strictly additive; existing build outcomes and constraint behavior are unchanged. Co-authored-by: Isaac --- CHANGELOG.md | 6 ++++++ .../macros/relations/materialized_view/create.sql | 3 +++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c5767bf9..d9bceceba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## dbt-databricks 1.11.8 (TBD) + +### Fixes + +- Warn when `contract.enforced: true` is set on a `materialized_view` model ([#1279](https://github.com/databricks/dbt-databricks/issues/1279)) + ## dbt-databricks 1.11.7 (Apr 17, 2026) ### Features diff --git a/dbt/include/databricks/macros/relations/materialized_view/create.sql b/dbt/include/databricks/macros/relations/materialized_view/create.sql index 5f0e49525..3639598b7 100644 --- a/dbt/include/databricks/macros/relations/materialized_view/create.sql +++ b/dbt/include/databricks/macros/relations/materialized_view/create.sql @@ -24,6 +24,9 @@ {%- set model_columns = model.get('columns', {}) -%} {%- set contract_config = config.get('contract') -%} {%- if contract_config and contract_config.enforced -%} + {%- do exceptions.warn( + "model '" ~ model.name ~ "' sets contract.enforced=true, but contracts are not supported for materialized_view. See https://docs.getdbt.com/docs/mesh/govern/model-contracts" + ) -%} {%- set model_constraints = model.get('constraints', []) -%} {%- else -%} {%- set model_constraints = [] -%} From 9c6396a87f7213919d68db63143ce30a43138cb8 Mon Sep 17 00:00:00 2001 From: Shubham Dhal Date: Sat, 25 Apr 2026 18:32:30 +0530 Subject: [PATCH 2/2] fix(#1279): clarify contract.enforced=true MV warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reword to call out dbt's official "not supported" stance and dbt-databricks' best-effort behavior that may change without notice. Drops the implication that we do nothing — we partially honor it. Co-authored-by: Isaac --- .../databricks/macros/relations/materialized_view/create.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbt/include/databricks/macros/relations/materialized_view/create.sql b/dbt/include/databricks/macros/relations/materialized_view/create.sql index 3639598b7..ce2b6eb42 100644 --- a/dbt/include/databricks/macros/relations/materialized_view/create.sql +++ b/dbt/include/databricks/macros/relations/materialized_view/create.sql @@ -25,7 +25,7 @@ {%- set contract_config = config.get('contract') -%} {%- if contract_config and contract_config.enforced -%} {%- do exceptions.warn( - "model '" ~ model.name ~ "' sets contract.enforced=true, but contracts are not supported for materialized_view. See https://docs.getdbt.com/docs/mesh/govern/model-contracts" + "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." ) -%} {%- set model_constraints = model.get('constraints', []) -%} {%- else -%}