[SPARK-56125][SQL] Simplify schema calculation for Merge Into Schema Evolution#55124
Open
szehon-ho wants to merge 2 commits intoapache:masterfrom
Open
[SPARK-56125][SQL] Simplify schema calculation for Merge Into Schema Evolution#55124szehon-ho wants to merge 2 commits intoapache:masterfrom
szehon-ho wants to merge 2 commits intoapache:masterfrom
Conversation
389ffac to
5637683
Compare
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.
What changes were proposed in this pull request?
Simplifies the schema evolution logic for MERGE INTO in two ways:
Replace pre-filtering source schema with post-filtering schema changes: Instead of building a pruned source schema (
sourceSchemaForSchemaEvolution) and then diffing it against the target, we now compute all schema diffs against the full source schema and filter the resultingTableChangeobjects to only those whose field paths fall under identity assignment paths. This eliminates the recursivefilterSchemafunction, theisEqualhelper (which was a duplicate ofisSameColumnAssignment), and theisPrefixhelper.Replace
originalTarget/originalSourcethreading withonIncompatiblecallback inResolveSchemaEvolution.computeSchemaChanges: The original target and source schemas were passed through every recursive call (7+ call sites across 3 methods) but only used once in the error case. A by-nameerrorparameter replaces both, reducing parameter count and improving readability.Also removes dead code: the
containsStarActioncheck insourceSchemaForSchemaEvolutionwas unreachable becauseactionsSchemaEvolutionReadyreturnsfalsefor star actions (viacase _ => false), preventingpendingSchemaChangesfrom callingsourceSchemaForSchemaEvolutionuntilResolveReferenceshas expanded all star actions.Why are the changes needed?
Code simplification and dead code removal. The existing logic was harder to follow due to the recursive schema pruning approach and redundant parameter threading.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Existing tests (the logic is semantically equivalent).