Skip to content

Commit 7f1ae0e

Browse files
gsolasabbenc-db
andauthored
fix: Remove external path on intermediate tables for python incremental models (#1161)
<!-- Please review our pull request review process in CONTRIBUTING.md before your proceed. --> <!--- Include the number of the issue addressed by this PR above if applicable. Example: resolves #1234 Please review our pull request review process in CONTRIBUTING.md before your proceed. --> ### Description This update changes how intermediate tables are handled for Python incremental models (with Materialization V2). Previously, when Python models were configured to save as external tables, their intermediate tables were also stored in the external path. This caused two main issues: - Concurrency problems: Even when using unique_tmp_table_suffix=True, all runs shared the same external path, leading to conflicts. - Unnecessary storage: Data from intermediate tables was not deleted when the tables were dropped, leaving unwanted files in the storage account. With this change, intermediate tables will be stored as managed tables, which will: - Prevent concurrency issues by ensuring each run uses a unique location. - Automatically remove intermediate data after dbt execution, keeping storage clean and efficient. <!--- Describe the Pull Request here --> ### 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` and added information about my change to the "dbt-databricks next" section. --------- Co-authored-by: Ben Cassell <98852248+benc-db@users.noreply.github.com>
1 parent d83f9f1 commit 7f1ae0e

2 files changed

Lines changed: 2 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
### Fixes
44

55
- Improve ANSI mode error handling for Python models and add debug instrumentation ([1157](https://github.com/databricks/dbt-databricks/pull/1157))
6+
- Remove external path on intermediate tables for incremental models (with Materialization V2) ([1161](https://github.com/databricks/dbt-databricks/pull/1161))
67

78
## dbt-databricks 1.10.10 (August 20, 2025)
89

dbt/include/databricks/macros/adapters/python.sql

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ except ImportError:
111111
{% macro create_python_intermediate_table(relation, compiled_code) %}
112112
{{ compiled_code }}
113113

114-
{%- set location_root = config.get('location_root', validator=validation.any[basestring]) -%}
115114
{%- set file_format = config.get('file_format', validator=validation.any[basestring])|default('delta', true) -%}
116115

117116
# --- Autogenerated dbt materialization code. --- #
@@ -171,11 +170,7 @@ writer = (
171170
.mode("overwrite")
172171
.option("overwriteSchema", "true")
173172
.format("{{ file_format }}")
174-
{%- if location_root is not none -%}
175-
{%- set model_path = adapter.compute_external_path(config, model, True) %}
176-
.option("path", "{{ model_path }}")
177-
{%- endif -%}
178173
)
179174

180175
writer.saveAsTable("{{ relation.render() }}")
181-
{% endmacro %}
176+
{% endmacro %}

0 commit comments

Comments
 (0)