Skip to content

Commit c233032

Browse files
authored
Fix schema removal issue from DROP VIEW and get_insert_overwrite_sql strategy (#590)
* schema is removed when dropping a temporary view (file format = Parquet) or when applying the get_insert_overwrite_sql strategy * update changelog * fix integration test * fix integration test, add updates(python model)
1 parent 3ebe6dd commit c233032

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Fix invalid Spark relation type: iceberg_table
88
- Fix Iceberg snapshot issue of incorrect DROP VIEW calls
99
- Upgrade dependencies: dbt-core 1.9.4, dbt-spark 1.9.2, moto 5.1.3.
10+
- Fix schema removal issue from DROP VIEW and get_insert_overwrite_sql strategy
1011

1112
## v1.9.2
1213
- Correctly handle EntityNotFound when trying to determine session state, setting state to does not exist instead of STOPPED.

dbt/include/glue/macros/materializations/incremental/incremental.sql

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,14 @@
137137

138138
{% if is_incremental == 'True' %}
139139
{% if is_tmp_relation_created == 'True' %}
140-
{{ glue__drop_relation(tmp_relation) }}
140+
{% if file_format != 'iceberg' %}
141+
{% call statement('drop_relation') -%}
142+
{%- set tmp_relation_view = tmp_relation.include(schema=false) -%}
143+
drop view if exists {{ tmp_relation_view }}
144+
{%- endcall %}
145+
{% else %}
146+
{{ glue__drop_relation(tmp_relation) }}
147+
{% endif %}
141148
{% endif %}
142149
{% if file_format == 'delta' %}
143150
{{ adapter.delta_update_manifest(target_relation, custom_location, partition_by) }}

dbt/include/glue/macros/materializations/incremental/strategies.sql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
{%- if file_format == 'iceberg' -%}
88
{%- set full_target_relation = glue__make_target_relation(target_relation, file_format) -%}
99
{%- set full_source_relation = glue__make_target_relation(source_relation, file_format) -%}
10+
{%- else -%}
11+
{%- set full_source_relation = source_relation.include(schema=false) -%}
1012
{%- endif -%}
1113
set hive.exec.dynamic.partition.mode=nonstrict
1214
dbt_next_query
1315
insert overwrite table {{ full_target_relation }}
1416
{{ partition_cols(label="partition") }}
15-
select {{dest_cols_csv}} from {{ full_source_relation }}
17+
select {{dest_cols_csv}} from {{ full_source_relation }}
1618
{% endmacro %}
1719

1820

0 commit comments

Comments
 (0)