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 @@ -2,6 +2,7 @@

### Fixes

- Let Predictive Optimization manage models with `auto_liquid_cluster` instead of running synchronous `OPTIMIZE` after materialization ([#1658](https://github.com/databricks/dbt-databricks/pull/1658) resolves [#1655](https://github.com/databricks/dbt-databricks/issues/1655))
- Skip unnecessary Unity Catalog constraint metadata queries for incremental models without enforced contracts ([#1643](https://github.com/databricks/dbt-databricks/pull/1643) resolves [#1641](https://github.com/databricks/dbt-databricks/issues/1641))
- Recreate materialized views when query schema drifts, honoring `on_configuration_change` ([#1621](https://github.com/databricks/dbt-databricks/pull/1621) resolves [#1359](https://github.com/databricks/dbt-databricks/issues/1359))
- Warn when documented columns are missing from V1 and V2 table and incremental models, and honor `persist_docs.columns` for V2 column comments ([#1563](https://github.com/databricks/dbt-databricks/pull/1563) ports [dbt-adapters#1684](https://github.com/dbt-labs/dbt-adapters/pull/1684), resolving [dbt-adapters#1690](https://github.com/dbt-labs/dbt-adapters/issues/1690)).
Expand Down
2 changes: 1 addition & 1 deletion dbt/include/databricks/macros/relations/optimize.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{%- elif var('DATABRICKS_SKIP_OPTIMIZE', 'false')|lower != 'true' and
var('databricks_skip_optimize', 'false')|lower != 'true' and
adapter.resolve_file_format(config) == 'delta' -%}
{%- if (config.get('zorder', False) or config.get('liquid_clustered_by', False)) or config.get('auto_liquid_cluster', False) -%}
{%- if config.get('zorder', False) or config.get('liquid_clustered_by', False) -%}
{%- call statement('run_optimize_stmt') -%}
{{ get_optimize_sql(relation) }}
{%- endcall -%}
Expand Down
6 changes: 3 additions & 3 deletions docs/flow/incremental_flow.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Incremental Flow

_Last updated: 2026-08-20_
_Last updated: 2026-08-31_

> Two diagrams follow: **Existing** is the default path, **New** is used when the
> `use_materialization_v2` behavior flag is enabled. See [flow/README.md](README.md) for what the
Expand Down Expand Up @@ -40,7 +40,7 @@ flowchart LR
NEWCFG --> GRANTS[Apply grants]
REPLACEDOCS --> GRANTS
DOCS --> GRANTS
GRANTS --> OPT[Run optimize]
GRANTS --> OPT[Run optimize for zorder / liquid_clustered_by]
OPT --> POST[Run post-hooks]
POST --> STATIC[Restore static overwrite mode for non-full-refresh insert_overwrite]
```
Expand Down Expand Up @@ -78,7 +78,7 @@ flowchart LR
CREATE --> GRANTS[Apply grants]
SAFE --> GRANTS
MERGE --> GRANTS
GRANTS --> OPT[Run optimize]
GRANTS --> OPT[Run optimize for zorder / liquid_clustered_by]
OPT --> PYCLEAN{Python model?}
PYCLEAN -- yes --> CLEAN[Drop intermediate relation]
PYCLEAN -- no --> POST[Run post-hooks]
Expand Down
4 changes: 2 additions & 2 deletions docs/flow/snapshot_flow.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Snapshot Flow

_Last updated: 2026-08-10_
_Last updated: 2026-08-31_

> Snapshots do **not** use the `use_materialization_v2` flag — there is a single path. Source:
> `dbt/include/databricks/macros/materializations/snapshot.sql`. Strategy dispatch and the
Expand Down Expand Up @@ -46,7 +46,7 @@ flowchart TD
CLEAN -- yes --> POSTSNAP[post_snapshot cleanup]
CLEAN -- no --> CONST
POSTSNAP --> CONST[Persist constraints]
CONST --> OPT[Run optimize]
CONST --> OPT[Run optimize for zorder / liquid_clustered_by]
OPT --> POSTOUT["Run post-hooks (outside transaction)"]
```

Expand Down
6 changes: 3 additions & 3 deletions docs/flow/table_flow.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Table Flow

_Last updated: 2026-08-10_
_Last updated: 2026-08-31_

> Two diagrams follow: **V1** is the default path, **V2** is used when the `use_materialization_v2`
> behavior flag is enabled. See [flow/README.md](README.md) for what the flag is and how the
Expand All @@ -27,7 +27,7 @@ flowchart LR
TAGS --> COLTAGS[Apply column tags]
COLTAGS --> DOCS[Persist docs]
DOCS --> CONSTRAINTS[Persist constraints]
CONSTRAINTS --> OPT[Run optimize]
CONSTRAINTS --> OPT[Run optimize for zorder / liquid_clustered_by]
OPT --> POST[Run post-hooks]
```

Expand All @@ -53,7 +53,7 @@ flowchart LR

CREATE --> GRANTS[Apply grants]
SAFE --> GRANTS
GRANTS --> OPT[Run optimize]
GRANTS --> OPT[Run optimize for zorder / liquid_clustered_by]
OPT --> PYCLEAN{Python model?}
PYCLEAN -- yes --> CLEAN[Drop intermediate relation]
PYCLEAN -- no --> POST[Run post-hooks]
Expand Down
10 changes: 9 additions & 1 deletion tests/unit/macros/relations/test_optimize_macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,16 @@ def test_macros_optimize_with_extraneous_info(self, config, var, template_bundle

assert result == "run_optimize_stmt"

def test_macros_optimize_skips_auto_liquid_clustering(self, config, template_bundle):
config["auto_liquid_cluster"] = True

result = self.render_bundle(template_bundle, "optimize")

assert result == ""

@pytest.mark.parametrize("key_val", ["DATABRICKS_SKIP_OPTIMIZE", "databricks_skip_optimize"])
def test_macros_optimize_with_skip(self, key_val, var, template_bundle):
def test_macros_optimize_with_skip(self, key_val, config, var, template_bundle):
config["liquid_clustered_by"] = ["foo"]
var[key_val] = True
r = self.render_bundle(template_bundle, "optimize")

Expand Down
Loading