Skip to content

Commit

Permalink
Not dropping table for incremental full refresh with delta (dbt-labs#287
Browse files Browse the repository at this point in the history
)

* Not dropping table for incremental full refresh with delta

* Updated changelog

* Simplified conditional logic according to suggestion

* Updated changelog

* Only drop table if not delta table

Co-authored-by: Jeremy Cohen <jtcohen6@gmail.com>

* Update changelog, trigger CircleCI tests

Co-authored-by: Jeremy Cohen <jeremy@dbtlabs.com>
Co-authored-by: Jeremy Cohen <jtcohen6@gmail.com>
  • Loading branch information
3 people authored and francescomucio committed Jul 26, 2022
1 parent d39b0a3 commit 43c1c2d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## dbt-spark 1.2.0rc1 (Release TBD)

- Incremental materialization updated to not drop table first if full refresh for delta lake format, as it already runs _create or replace table_ ([#286](https://github.com/dbt-labs/dbt-spark/issues/286), [#287](https://github.com/dbt-labs/dbt-spark/pull/287/))

### Contributors
- [@grindheim](https://github.com/grindheim) ([#287](https://github.com/dbt-labs/dbt-spark/pull/287/))

## dbt-spark 1.2.0b1 (June 24, 2022)

### Fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@

{{ run_hooks(pre_hooks) }}

{% set is_delta = (file_format == 'delta' and existing_relation.is_delta) %}

{% if existing_relation is none %}
{% set build_sql = create_table_as(False, target_relation, sql) %}
{% elif existing_relation.is_view or full_refresh_mode %}
{% do adapter.drop_relation(existing_relation) %}
{% if not is_delta %} {#-- If Delta, we will `create or replace` below, so no need to drop --#}
{% do adapter.drop_relation(existing_relation) %}
{% endif %}
{% set build_sql = create_table_as(False, target_relation, sql) %}
{% else %}
{% do run_query(create_table_as(True, tmp_relation, sql)) %}
Expand Down

0 comments on commit 43c1c2d

Please sign in to comment.