[SPARK-57158][SQL] ExplainUtils: extract operator ID assignment phase from processPlan into a private helper#56216
Open
markj-db wants to merge 2 commits into
Conversation
… from processPlan into a private helper ### What changes were proposed in this pull request? Extract the operator-ID-assignment phase of `ExplainUtils.processPlan` into a private `assignOperatorIds(plan, idMap)` helper. `processPlan` now initializes the idMap, delegates all ID assignment to `assignOperatorIds`, then performs the text-output pass over the returned subqueries and optimized-out exchanges. ### Why are the changes needed? `processPlan` conflated two independent sequential phases in one 40-line body: (1) populating an IdentityHashMap with operator IDs by traversing the plan tree, subqueries, and adaptively-optimized-out exchanges (SPARK-42753); and (2) calling `processPlanSkippingSubqueries` to format the verbose explain string. Extracting phase 1 shortens `processPlan` to its output logic and makes the boundary between the two phases explicit. No behavior change. ### Does this PR introduce any user-facing change? No. ### How was this patch tested? Added `ExplainUtilsSuite` covering operator ID uniqueness, WholeStageCodegen tag propagation, thread-local restoration, and subquery section output. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude (Anthropic)
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?
Extract the operator-ID-assignment phase of
ExplainUtils.processPlaninto a privateassignOperatorIds(plan, idMap)helper.processPlannow initializes the idMap, delegates all ID assignment toassignOperatorIds, then performs the text-output pass over the returned subqueries and optimized-out exchanges.Why are the changes needed?
processPlanconflated two independent sequential phases in one ~40-line body:IdentityHashMapwith monotonically-increasing operator IDs.processPlanSkippingSubquerieson each discovered subtree to format the verbose explain string.These phases are sequential and independent: the text-output pass only begins after ID assignment is fully complete. Extracting phase 1 into
assignOperatorIdsshortensprocessPlanto its output logic and makes the boundary between the two phases explicit. No behavior change.Does this PR introduce any user-facing change?
No.
How was this patch tested?
Added
ExplainUtilsSuitecovering:processPlansetsCODEGEN_ID_TAGon nodes insideWholeStageCodegenExeclocalIdMapis restored to its prior value afterprocessPlanreturnsWas this patch authored or co-authored using generative AI tooling?
Generated-by: Claude (Anthropic)