Check for incremental data
Sat May 06 2023 14:45:35 GMT+0000 (Coordinated Universal Time)
Saved by
@klleee28
#dbt
#incremental
#materialize
{{
config(
materialized="incremental",
unique_key="page_view_id" -- This line is the key to replace duplicates
)
}}
with events as (
select * from {{ source('schema', 'table') }}
{% if is_incremental() %}
where collector_tstamp >= ( select dateadd('day', -3, max(max_collector_tstamp)) from {{ this }}
{% endif %}
)
content_copyCOPY
Build an incremental model with 3 days time in buffer.
Existing records that are duplicates will be replaced, while new records will be inserted.
Comments