Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
- Warn when `contract.enforced: true` is set on a `materialized_view` model ([#1279](https://github.com/databricks/dbt-databricks/issues/1279))
- Fix `materialized_view` models with `databricks_tags` silently going stale on `dbt run`. `MaterializedViewAPI._describe_relation` was not fetching `information_schema.tags`, so existing tags always parsed as empty, producing a spurious tag diff that routed the materialization to `ALTER ... SET TAGS` instead of `REFRESH MATERIALIZED VIEW` ([#1419](https://github.com/databricks/dbt-databricks/issues/1419))
- Fix `dbt docs generate` failing with `RuntimeError: Tables contain columns with the same names ... but different types` during catalog merge across schemas ([#1392](https://github.com/databricks/dbt-databricks/issues/1392))
- Fix view materialization incorrectly producing a no-op instead of forcing recreation when `--full-refresh` is provided alongside `view_update_via_alter: true` and `use_materialization_v2: true` ([#1404](https://github.com/databricks/dbt-databricks/issues/1404))

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

Expand Down
3 changes: 3 additions & 0 deletions dbt/include/databricks/macros/materializations/view.sql
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@
{% endmacro %}

{% macro relation_should_be_altered(existing_relation) %}
{% if should_full_refresh() %}
{{ return(False) }}
{% endif %}
{% set update_via_alter = config.get('view_update_via_alter', False) | as_bool %}
{% if (existing_relation.is_view or existing_relation.is_metric_view) and update_via_alter %}
{% if existing_relation.is_hive_metastore() %}
Expand Down
32 changes: 32 additions & 0 deletions tests/functional/adapter/views/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,22 @@ def test_view_update_nothing(self, project):
assert results[0][2] == "This is the id column"


class BaseUpdateFullRefresh(BaseUpdateView):
"""Ensure that a full refresh forces a recreation even when there are no changes."""

def test_view_update_full_refresh(self, project):
util.run_dbt(["build"])
# Should not no-op, but we at least ensure it runs successfully.
# The logs should contain "Using replace_with_view" but we can't easily assert that.
util.run_dbt(["run", "--full-refresh"])

results = project.run_sql(
"describe extended {database}.{schema}.initial_view",
fetch="all",
)
assert results[0][2] == "This is the id column"


class BaseUpdateTblProperties(BaseUpdateView):
def test_view_update_tblproperties(self, project):
util.run_dbt(["build"])
Expand Down Expand Up @@ -165,6 +181,22 @@ def project_config_update(self):
}


@pytest.mark.skip_profile("databricks_cluster")
class TestUpdateViewViaAlterFullRefresh(BaseUpdateFullRefresh):
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"flags": {"use_materialization_v2": True},
"models": {
"+view_update_via_alter": True,
"+persist_docs": {
"relation": True,
"columns": True,
},
},
}


@pytest.mark.skip_profile("databricks_cluster")
class TestUpdateViewViaAlterQuery(BaseUpdateQuery):
@pytest.fixture(scope="class")
Expand Down