-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lisätty onnistuneiden ajojen kirjanpito
- Loading branch information
Matz Rasmus
committed
Oct 25, 2024
1 parent
3c11b5d
commit 275c6e9
Showing
3 changed files
with
41 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{% macro stg_end() -%} | ||
{%- if target.name == 'prod' %} | ||
with data as ( | ||
select | ||
model, | ||
replace(regexp_replace(split_part(model, '.', 3),'stg_',''),'"','') as raw_table, | ||
start_time | ||
from raw.dbt_runs dr | ||
where model = '{{ this }}' | ||
) | ||
|
||
merge into raw.completed_dbt_runs as t | ||
using data as s | ||
on t.model = s.model | ||
when matched | ||
then update set start_time=s.start_time | ||
when not matched | ||
then insert values (model,raw_table,start_time) | ||
{% endif %} | ||
{%- endmacro %} |
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,17 @@ | ||
{% macro stg_start() -%} | ||
{%- if target.name == 'prod' %} | ||
with data as ( | ||
select | ||
'{{ this }}' as model, | ||
current_timestamp as start_time | ||
) | ||
|
||
merge into raw.dbt_runs as t | ||
using data as s | ||
on t.model = s.model | ||
when matched | ||
then update set start_time=s.start_time | ||
when not matched | ||
then insert values (model,start_time) | ||
{% endif %} | ||
{%- endmacro %} |