make model incremental

This commit is contained in:
Pablo Martin 2024-06-14 16:01:33 +02:00
parent eaf1a87ab3
commit 79345a6ab7

View file

@ -1,3 +1,5 @@
{{ config(materialized="incremental", unique_key="id_exchange_rate") }}
with
raw_exchange_rates as (select * from {{ source("xedotcom", "exchange_rates") }}),
stg_xedotcom__exchange_rates as (
@ -17,3 +19,8 @@ with
)
select *
from stg_xedotcom__exchange_rates
{% if is_incremental() %}
where
dwh_extracted_at_utc
>= ((select max(dwh_extracted_at_utc) from {{ this }}) - interval '7 days')
{% endif %}