-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
99 additions
and
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
|
||
|
||
{%- macro get_most_recent_record(relation) -%} | ||
|
||
{#-- do not run the query in parsing mode #} | ||
{%- if not execute -%} | ||
{{ return('') }} | ||
{%- endif -%} | ||
|
||
{# fix for tmp suffix #} | ||
{%- set relation = api.Relation.create(identifier=relation.name, schema=relation.schema) -%} | ||
{%- set partition_col = config.partition_by.render() -%} | ||
|
||
{%- call statement('_', fetch_result=True) -%} | ||
|
||
select max(partition_col) as start_date from {{ relation }} | ||
|
||
{%- endcall -%} | ||
|
||
{%- set data = load_result('_')['table'].rows -%} | ||
{{ return(data[0]['start_date']) }} | ||
|
||
{%- endmacro -%} | ||
|
||
|
||
|
||
{%- macro get_start_date() -%} | ||
|
||
{%- set start_date -%} | ||
|
||
{%- if config.incremental_strategy == 'insert_overwrite' -%} | ||
|
||
{%- if config.partitions -%} least({{partitions|join(',')}}) | ||
{%- elif config.partition_by.data_type == 'date' -%} _dbt_max_partition | ||
{%- else -%} date(_dbt_max_partition) | ||
{%- endif -%} | ||
|
||
{%- else -%} | ||
|
||
'{{ get_most_recent_record() }}' | ||
|
||
{%- endif -%} | ||
|
||
{%- endset -%} | ||
|
||
{%- do return(start_date) -%} | ||
|
||
{%- endmacro -%} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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