Repository navigation
[spark] Narrow cached source columns in shared Data Evolution MERGE joins - #11322
Closed
JustinBinber wants to merge 9 commits into
Closed
JustinBinber wants to merge 9 commits into
JustinBinber wants to merge 9 commits into
Conversation
2 tasks done
JingsongLi
reviewed
Nov 23, 2026
JingsongLi
left a comment
Contributor
There was a problem hiding this comment.
The benchmark establishes a concrete shuffle and disk-cache reduction for wide INSERT payloads. I reran all 17 MERGE tests on Spark 3.5.9 and all 17 on Spark 4.1.4 with the PR integrated over current master. The SQL check below surfaced a source consistency issue. Please put the repository-wide JDK setup retry in a separate PR so it can be reviewed independently of MERGE.
This was referenced Nov 27, 2026
Contributor
Author
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.
Fixes #11323
Purpose
The shared Data Evolution MERGE join currently caches source columns needed only by INSERT along with the matching and UPDATE fields. For a wide source this sends otherwise unused payload through the shared shuffle and executor disk cache.
This adds a default-off option,
data-evolution.merge-into.join-reuse.narrow-source.enabled, used with the existing join-reuse option. The shared join retains matching and UPDATE dependencies plus presence markers. INSERT obtains unmatched source keys from that result and uses a null-safe membership join against a reread of the pinned source. This remains a source scan, not a positional read. DE-source RowID reads belong to a separate change.The reread is restricted to a single INT/BIGINT equality key and safe analyzed Paimon append-table source plans whose snapshot can be pinned. The same source snapshot and attribute ExprIds are preserved. Unsupported sources/plans, self reads, composite branch readers, missing snapshot metadata and incompatible schema-only evolution retain the existing path. Users do not have to assert a
stableSourcepromise. NULL keys and duplicate unmatched rows retain multiset semantics, and cached matches are released on failure.Example opt-in:
Source:
4964431e3d56e161dd29cf87fe3920dd6881a6c2. Synthetic reproduction sources, exact SQL generators, nine sample metrics, validation summaries and limitations. The reproduction branch is separate from this production PR diff.Tests
Validation: 17 relevant tests on Spark 3.5.9 / Scala 2.12 / JDK 8 and 17 on Spark 4.1.4 / Scala 2.13 / JDK 17. The Spark 4.0 mirror compiled and passed module validation; no Spark 4.0 runtime result is claimed. Tests cover snapshot recomputation/time travel, schema-only changes, retained tags, branches and composite readers, empty sources, unsupported plans, NULL equality, false UPDATE conditions, duplicate unmatched rows and failure cleanup.
Performance observations
Bounded benchmark: one 4-core/16-GiB physical host, two one-core/1-GiB Executor JVMs, 4-GiB Driver, Spark 3.5.9 with AQE/coalescing enabled. Target: 32,768 two-row DE append files, 259 columns; UPDATE changes 128 columns. Ordinary append source: 39,321 rows, with a real 8-KiB logical INSERT-only field where applicable. Every arm used a fresh target clone/JVM, identical source dataset and settings, complete OS input warm-up, full SQL timing, and independent complete-result/RowID/snapshot/layout validation.
These are screening observations, not significant or stable speedup claims. All-INSERT used the fallback path with zero shared-cache/shuffle bytes. The no-wide-field control had identical shuffle/cache bytes for existing/narrow sharing, but the narrow-enabled timing was 2.21% higher in this single observation. No default enablement or automatic INSERT-ratio threshold is proposed.
For the 90%-INSERT wide-field case, existing/narrow sharing produced 316.79/10.77 MB shuffle, 312.20/18.78 MB peak shared disk cache, and 1,300.89/381.79 MB sampled process writes. Sampled process-tree RSS was higher: 3.78/4.80 GiB (+27%); the no-sharing reference was 4.66 GiB. The full-SQL observation improved 5.61% relative to existing sharing. Source FileIO returned approximately 164 MB in both paths; this is not physical disk/network traffic. Sampled process counter deltas are interior lower bounds, not complete process totals.
All nine SQLs and independent validations passed without timed task failure or disk spill. Two short warm INSERT-range SELECT probes were also retained, including an all-INSERT narrow-enabled observation 4.28% slower than existing sharing; they do not prove general query non-regression. The higher memory observation and these limited samples are explicit tradeoffs of the opt-in path.
Negative/lifecycle evidence is retained: an all-INSERT pre-launch disk-budget rejection (no SQL executed), old build cleanup before continuing the missing phase. Successful SQL samples were never replayed or selectively replaced. The 5-GiB disk and 3.2-GiB available-memory floors were not lowered.
Merge preview against current master
48da48ae2e7ba1f29fb380218481d3555c62f1c0has no conflicts. The retained runtime tests bind to the unchanged feature source; current-master integration still requires CI acceptance.Snapshot rollback follow-up
The source binding now retains the resolved Snapshot in a private MERGE cache. Both reads plan against the original manifest references even if rollback reuses the numeric ID. If those files are unavailable, the read fails before target commit. Sources configured to skip lost or corrupt files use the existing shared path. The Spark 4.0 mirror uses the same binding. The regression rolls back and writes a different snapshot with the same ID and schema.
The generated CoreOptions reference stays in this PR. The repository-wide JDK setup retry was reverted in
3dc98d1fbband has no workflow diff in this PR. The performance samples above are from the earlier4964431source.