-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for incremental materialization with ingestion time partition…
… tables
- Loading branch information
Showing
5 changed files
with
221 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
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
34 changes: 34 additions & 0 deletions
34
...s/integration/incremental_schema_tests/models/incremental_time_ingestion_partitioning.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,34 @@ | ||
{{ | ||
config( | ||
materialized='incremental', | ||
unique_key='id', | ||
on_schema_change='append_new_columns', | ||
partition_by={ | ||
"field": "date", | ||
"data_type": "timestamp", | ||
"time_ingestion_partitioning": true | ||
}, | ||
) | ||
}} | ||
|
||
{% set string_type = 'string' %} | ||
|
||
WITH source_data AS (SELECT * FROM {{ ref('model_a') }} ) | ||
|
||
{% if is_incremental() %} | ||
|
||
SELECT id, | ||
cast(field1 as {{string_type}}) as field1, | ||
cast(field2 as {{string_type}}) as field2, | ||
cast(field3 as {{string_type}}) as field3, | ||
cast(field4 as {{string_type}}) as field4 | ||
FROM source_data WHERE id NOT IN (SELECT id from {{ this }} ) | ||
|
||
{% else %} | ||
|
||
SELECT id, | ||
cast(field1 as {{string_type}}) as field1, | ||
cast(field2 as {{string_type}}) as field2 | ||
FROM source_data where id <= 3 | ||
|
||
{% endif %} |
Oops, something went wrong.