incremental model (Merge) without update

create your own incremental strategy and configure the strategy to ur model using config function
you create the incremental strategy macro and write your merge logic.
dbt identifies the macro with the name get_incremental_{strategy}_sql so you have to create macro with the above name.
dbt internally passes the below arguments to the user defined incremental strategy macro

{'target_relation': target_relation, 'temp_relation': tmp_relation, 'unique_key': unique_key, 'dest_columns': dest_columns, 'predicates': incremental_predicates }

you have to return a merge sql from the macro, dbt runs the sql on the configured database

user defined incremental strategy:

{% macro get_incremental_{strategy}_sql(arg_dict) %}
 merge logic
  {{ return (merge_sql_query) }}

{% endmacro %}
1 Like