The problem I’m having
I have a stored proc which I am trying to convert to dbt model.
stored prod:
Merge into table_a t
using(select distinct
t1.col1,
t2.col2
from table_b t1 inner join jable_b t2 on t1.id = t2.id) U on T.id = U.id
when not matched then insert(
col1, col2)
when matched then update set
col2 = U.col2)
i have my dbt model as below
config(
materialized = incremental
unique key = id
incremental strategy = merge
merge exclude columns=[col1] # as I dont want to merge this
Now the issue is
- I want to select a particular column only when I it is a mrege record.
say I have updated_datetime column , for the first load, we do not insert update_datetime instead we have created_datetime. and have update_datetime as null. but when I do a merge for that record, I need the update_datetime to get updated with latest datetime and do not udpate create_datetime.
unable to achieve this . please help
added exclude merge columns with create_datetime. but not sure how to update update_datetime column alone when the row is a merge