Repository navigation
[spark] Extend disjoint INSERT optimization in Data Evolution MERGE - #11565
Open
JustinBinber wants to merge 1 commit into
Open
JustinBinber wants to merge 1 commit into
JustinBinber wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Fixes #11564.
This extends #11526, which used predicate disjointness for the native delete-marker alternative discussed in #11174. For each conditional INSERT action, prove that its analyzed source attribute equals a different non-null literal from a required ON conjunct. If every INSERT action passes, filter the source with the OR of these conditions and let MergeRows retain first-applicable action semantics.
The INSERT proof is independent of matched UPDATE, matched DELETE and the separate NOT MATCHED BY SOURCE work. Shared join reuse remains the first choice when present. Overlapping or unproven conditions use the existing anti-join. The target split relation is evaluated on demand, which also avoids eager target-side pruning in the insert-only case. The existing single-snapshot commit publishes all prepared changes.
Tests
Local benchmark
Spark 3.5.9, WSL Linux
local[2]and AQE. A 128-column, 100,000-row target in 512 files received 5,000 flagged one-column UPDATEs and 1,250 flagged INSERTs. Each arm used the same SQL and integration classpath, with the native MERGE command as the only code difference. We rotated the order across three pairs, using a fresh JVM and target clone for each run.The optimized plan removed INSERT LeftAnti in all three runs. All six runs passed full-row and RowID validation and published one snapshot. Shuffle write was 25.49 MB in each run. These are single-host results for the marked workload.