I have model dest_pos.sq
l where dest_pos
snowflake table is empty for the first initial load and i am trying to insert into dest_pos
snowflake table from stg_kopr
table. When i build the model in dbt it runs successfully but it does not insert into dest_pos
snowflake table.
It looks like the where
condition is not getting satisfied and i need to use for example OR
condition in where
clause to handle empty dest_pos
table for the first time but dont know how to do it.
where load_timestamp > (select max(load_timestamp) from {{ this }})
Below is the model in dbt:
{{
config(
materialized='incremental',
unique_key= 'resd',
incremental_strategy='merge',
merge_update_columns = ['resd']
)
}}
with stg_kopr as (
select * from {{ ref('stg_kopr') }}
)
select resd,
pord,
edt
from stg_kopr
{% if is_incremental() %}
where load_timestamp > (select max(load_timestamp) from {{ this }})
{% endif %}