Skip to content

Conversation

@mi-volodin
Copy link
Contributor

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

  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • I have updated the CHANGELOG.md and added information about my change to the "dbt-databricks next" section.

@mi-volodin mi-volodin marked this pull request as ready for review May 12, 2025 18:33
@mi-volodin
Copy link
Contributor Author

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.

Copy link
Collaborator

@benc-db benc-db left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. I'll need to sleep on the name of the config, but the approach and test looks good.

@mi-volodin
Copy link
Contributor Author

Yep, of course, I'll write a docs entry meanwhile.

@mi-volodin
Copy link
Contributor Author

For transparency - it was decided to pause this PR activities until the principal decision would be made to introduce that functionality in that form.

@asos-dipeshbhundia
Copy link

@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.

@mi-volodin
Copy link
Contributor Author

@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.

@asos-dipeshbhundia
Copy link

@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.

image

The merge is pretty much just a cut down version of get_incremental_merge_sql
image

@mi-volodin
Copy link
Contributor Author

Did you create your own merge macro to use it?

@benc-db
Copy link
Collaborator

benc-db commented Jan 8, 2026

@sd-db the person in dbt Labs product that pushed back on this is no longer there. We should consider bringing this up again.

@asos-dipeshbhundia
Copy link

yes, i created my own version of the existing merge pattern cutting down the existing options to keep it simple
complex_merge.sql

@mi-volodin
Copy link
Contributor Author

@benc-db great 😄
Then I will rebase the changes on main or, if 1.11.4 will be released, on 1.11 latest, right?

@benc-db
Copy link
Collaborator

benc-db commented Jan 9, 2026

@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 :)

@mi-volodin
Copy link
Contributor Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for Multiple Actions in MERGE and Column-Specific Updates

3 participants