The problem I’m having
I want to use the incremental model merge statement, but if the row isn’t matched by the source I want to delete it in the target table
The context of why I’m trying to do this
We have some pipelines where data may exist (current example is a table of orders that are in draft, so have a number of products on them at one stage, but I only want to keep the final version of the order, when some of these products have been removed)
What I’ve already tried
To build a new macro using the existing merge macro here: https://github.com/dbt-labs/dbt-core/blob/main/core/dbt/include/global_project/macros/materializations/models/incremental/merge.sql
However I’m not sure how to use this in my dbt instance.
My ideal scenario would be to add my updated version to the list of incremental strategies so I can select on the models that I need to.
Failing that, some advice on how I can set it up to run for my sql