Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do we use the merge statement inside Incremental model for SCD 1 Implementation

Tags:

dbt

I am trying to implement the scd1 in Data Build Tools using the Merge query. But I am not getting the exact way to write this query in Incremental model.

Can anyone show where we have to write the merge query.

{{
    config(
        materialized='incremental'
    )
}}

<MERGE QUERY HERE> 

{% if is_incremental() %}
where last_modified_date > '2020-07-11'
{% endif %}
like image 264
Vipendra Singh Avatar asked Sep 16 '25 14:09

Vipendra Singh


1 Answers

You don't actually need to write the merge statement, dbt will take care of that for you. You should write a query that will return the records you want to upsert. You can then check the log for the merge query dbt generates.

Also check out the dbt docs on configuring incremental models: https://docs.getdbt.com/docs/building-a-dbt-project/building-models/configuring-incremental-models#what-is-an-incremental_strategy

like image 200
PowdyPowPow Avatar answered Sep 19 '25 06:09

PowdyPowPow