Repository navigation
[spark] Skip redundant INSERT anti-join in Data Evolution MERGE - #11526
Open
JustinBinber wants to merge 2 commits into
Open
JustinBinber wants to merge 2 commits into
JustinBinber wants to merge 2 commits 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 #11525.
The wide-table replacement work in #11174 compared an atomic delete-and-append procedure with a native MERGE using delete markers. Both publish deletions and inserted rows together in one Paimon snapshot. This PR improves the existing SQL path.
For delete-only MERGE with one INSERT action, the command checks whether a required ON conjunct and the INSERT predicate compare the same resolved source attribute to distinct non-NULL literals. For example, rows satisfying
s.op = 'I'cannot satisfy an ON predicate that requiress.op = 'D'. The INSERT path filters that source directly and keeps the existing assignment and write preparation. Unsupported and overlapping predicates retain the current plan. The matched DELETE path, conflict validation, and single snapshot publication use existing logic.Tests
LeftAntion the baseline. The candidate removes it, preserves duplicate incoming rows and the unaffected RowIDs, and publishes one snapshot.Local benchmark
Spark 3.5.9 with AQE, Java 8, WSL Linux
local[2], 128 columns and 100,000 target rows in 512 files. The fixed input replaces 5,000 rows and appends 1,250 new rows. Three runs per arm in rotating order used fresh target clones and fresh JVMs. The two native arms ran identical SQL on the same integration classpath with only the MERGE command changed. The procedure from #11174 is a reference.CALL replace_by_keysThe native fast path removed the INSERT anti join in all three runs. It lowered median full SQL time by 6.7%, target FileIO bytes returned by 33.3%, and Spark task CPU by 12.1% on this single-host workload. All nine runs passed full-row and RowID checks, published one snapshot, and wrote 148.14 MB in three new data files.