-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support copy partitions option for insert overwrite mode
- Loading branch information
Showing
8 changed files
with
164 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
kind: Features | ||
body: Optimize insert_overwrite incremental strategy with WRITE_TRUNCATE / Partition | ||
copy | ||
time: 2022-10-20T22:39:14.091878+02:00 | ||
custom: | ||
Author: Kayrnt | ||
Issue: "77" | ||
PR: "167" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...query_test/incremental-strategy-models/incremental_overwrite_day_with_copy_partitions.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{{ | ||
config( | ||
materialized="incremental", | ||
incremental_strategy='insert_overwrite', | ||
cluster_by="id", | ||
partition_by={ | ||
"field": "date_time", | ||
"data_type": "datetime", | ||
"copy_partitions": "true" | ||
} | ||
) | ||
}} | ||
|
||
|
||
with data as ( | ||
|
||
{% if not is_incremental() %} | ||
|
||
select 1 as id, cast('2020-01-01' as datetime) as date_time union all | ||
select 2 as id, cast('2020-01-01' as datetime) as date_time union all | ||
select 3 as id, cast('2020-01-01' as datetime) as date_time union all | ||
select 4 as id, cast('2020-01-01' as datetime) as date_time | ||
|
||
{% else %} | ||
|
||
-- we want to overwrite the 4 records in the 2020-01-01 partition | ||
-- with the 2 records below, but add two more in the 2020-01-02 partition | ||
select 10 as id, cast('2020-01-01' as datetime) as date_time union all | ||
select 20 as id, cast('2020-01-01' as datetime) as date_time union all | ||
select 30 as id, cast('2020-01-02' as datetime) as date_time union all | ||
select 40 as id, cast('2020-01-02' as datetime) as date_time | ||
|
||
{% endif %} | ||
|
||
) | ||
|
||
select * from data | ||
|
||
{% if is_incremental() %} | ||
where date_time >= _dbt_max_partition | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.