MERGE with explicit actions, support for multi-actions
Resolves #949
Description
This PR extends the capability of Merge strategy configuration and allow to completely override actions block with an explicit statement.
E.g. it allows to define multiple actions with multiple conditions and tune this part at developer's convenience.
when matched and ... then update
...
when matched and ... then delete
when not matched and ... then insert
...
Checklist
- [x] I have run this code in development and it appears to resolve the stated issue
- [x] This PR includes tests, or tests are not required/relevant for this PR
- [ ] I have updated the
CHANGELOG.mdand added information about my change to the "dbt-databricks next" section.
There are some extra actions on docs + changelog, but the code is ready for review.
@benc-db could you please trigger the tests on your side? My functional tests with snapshots traditionally doesn't work.
Yep, of course, I'll write a docs entry meanwhile.
For transparency - it was decided to pause this PR activities until the principal decision would be made to introduce that functionality in that form.
@mi-volodin @benc-db are there any further updates on this?
We have a similar need for multiple matches and I'd rather use something native rather than creating a modified version.
With the native databricks merge functionality progressing very fast, it makes sense to have custom sql expressions for the merge rather than loads of potential keys and extra config options which become increasingly more complex to maintain.
@asos-dipeshbhundia there were no further proceedings, IIRC mostly due to the coincidental release of dbt fusion at that time.
I personally also still would like to have this functionality, but only if the concept would be approved to go on with by @benc-db . The branch is apparently outdated and I'll be happy to rebase it if needed.
@mi-volodin Thanks, internally we have created our own incremental strategy to allow custom merge actions. We have an extra property under meta called custom merge actions which allows sql.
The merge is pretty much just a cut down version of get_incremental_merge_sql
Did you create your own merge macro to use it?
@sd-db the person in dbt Labs product that pushed back on this is no longer there. We should consider bringing this up again.
yes, i created my own version of the existing merge pattern cutting down the existing options to keep it simple complex_merge.sql
@benc-db great 😄
Then I will rebase the changes on main or, if 1.11.4 will be released, on 1.11 latest, right?
@mi-volodin I'd hold off on rebasing, as they might still tell us not to merge it. I'm just suggesting its worth it for us to bring up in our product meetings with them to see if their position has softened. Thanks however for your eagerness to improve the adapter for others :)
@benc-db ah 🥲 sorry, I've read it wrongly. Then keeping it on ice until there will be some news.
At least now there's a proof that it's not only needed, but actually achieved (in a potentially non-uniform way if implemented by others from scratch) with the ad-hoc strategy overloading. For me it looks like quite a good argument to proceed.
Hello @benc-db @mi-volodin, I think this merge feature is very important. It is a core functionality of DBT Databricks for data engineering and BI use cases. Will there be any progress on this, please?
@benc-db just for the case I rebased to the tip of the main 😉
@sd-db @tejassp-db
Hi! Got the message from Ben that you are now the core maintainers. Therefore tagging you with a kind request to look into the topic.
I can share the context if needed.
@sd-db @jprakash-db sorry, just a kind reminder to look into this PR. At least some feedback on the plans is really-really appreciated.
Sorry on the long wait, had been busy with a few other things. Let me a take a look next week. On the top of my list 👍
@sd-db Any news? At least to understand if we are still up to consider this concept.
@sd-db Any news on this ?
@mi-volodin Thanks, finally got to this PR. Overall direction seems good. Should be open to this in 1.13. I think the current PR can do a bit more on testing, the other think I am concerned on is dbt-core warnings; which is raised on every config that is not documented in the json_schema (need to check a bit more); but think should be fine for this use-case as this is a sufficiently advanced use-case and I assume folks who need this should be able to work through the warnings etc.