Skip to content

Commit 4b8a202

Browse files
authored
Fix legacy incremental materialization (#178)
1 parent 1a0649e commit 4b8a202

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

Diff for: CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### Release [1.4.7], 2023-08-09
2+
#### Bug Fix
3+
- Fixed an exception in "legacy" incremental materializations that are not distributed
4+
15
### Release [1.4.6], 2023-07-27
26
#### Bug fix
37
- Lightweight deletes could fail in environments where the HTTP session was not preserved (such as clusters behind a non-sticky

Diff for: dbt/adapters/clickhouse/__version__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version = '1.4.6'
1+
version = '1.4.7'

Diff for: dbt/include/clickhouse/macros/materializations/incremental.sql

+5-3
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,14 @@
137137
{% macro clickhouse__incremental_legacy(existing_relation, intermediate_relation, on_schema_change, unique_key, is_distributed=False) %}
138138
{% set new_data_relation = existing_relation.incorporate(path={"identifier": model['name'] + '__dbt_new_data'}) %}
139139
{{ drop_relation_if_exists(new_data_relation) }}
140-
{%- set distributed_new_data_relation = existing_relation.incorporate(path={"identifier": model['name'] + '__dbt_distributed_new_data'}) -%}
141140

142141
{%- set inserted_relation = intermediate_relation -%}
143142
{%- set inserting_relation = new_data_relation -%}
144143

145144
-- First create a temporary table for all of the new data
146145
{% if is_distributed %}
147146
-- Need to use distributed table to have data on all shards
147+
{%- set distributed_new_data_relation = existing_relation.incorporate(path={"identifier": model['name'] + '__dbt_distributed_new_data'}) -%}
148148
{%- set inserting_relation = distributed_new_data_relation -%}
149149
{{ create_distributed_local_table(distributed_new_data_relation, new_data_relation, existing_relation, sql) }}
150150
{% else %}
@@ -190,8 +190,10 @@
190190
{% endcall %}
191191

192192
{% do adapter.drop_relation(new_data_relation) %}
193-
{{ drop_relation_if_exists(distributed_new_data_relation) }}
194-
{{ drop_relation_if_exists(distributed_intermediate_relation) }}
193+
{% if is_distributed %}
194+
{{ drop_relation_if_exists(distributed_new_data_relation) }}
195+
{{ drop_relation_if_exists(distributed_intermediate_relation) }}
196+
{% endif %}
195197

196198
{% endmacro %}
197199

0 commit comments

Comments
 (0)