Open chamini2 opened 2 years ago
I have a potentially interesting idea:
what if we leverage the existing dbt macros to do the merge?
so the operation would be:
i am thinking this could help: https://github.com/dbt-labs/dbt-core/blob/main/core/dbt/include/global_project/macros/materializations/snapshots/snapshot_merge.sql
and for dbt-bigquery, maybe we could use this: https://github.com/dbt-labs/dbt-bigquery/blob/main/dbt/include/bigquery/macros/materializations/snapshot.sql
and so on
Curious to see if this would lead anywhere.
We are avoiding updates for now and just support append and overwrite behavior for the new write_to_model
function (#249).
Initial proposal
The idea of this function is to be able to update a model table after it has been run (as an after-hook).
An example scenario would be:
Then, the after-hook:
How would the actual SQL statement look?
SQL does not match this kind of operation of inserting data on already existing rows very well. So you usually are updating data based on other database data or not doing it in big batches as we will.
The following SQL statement should work. However, more ideas may come up.