[SPARK-59160][SQL]. Move the currentStageID counter to AdaptiveExecutionCont… - #58459
Open
ahshahid wants to merge 4 commits into
Open
[SPARK-59160][SQL]. Move the currentStageID counter to AdaptiveExecutionCont…#58459ahshahid wants to merge 4 commits into
ahshahid wants to merge 4 commits into
Conversation
…ext to avoid clash of stageIDs when sharing the stages
ahshahid
marked this pull request as draft
September 1, 2026 23:17
…ext to avoid clash of stageIDs when sharing the stages. two getter methods. get and getAndIncrement
…ext to avoid clash of stageIDs when sharing the stages. two getter methods. get and getAndIncrement
…ext to avoid clash of stageIDs when sharing the stages. fix test failure due to inadvertent getAndDecrement instead of getAndIncrement
ahshahid
marked this pull request as ready for review
September 2, 2026 07:53
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.
…ext to avoid clash of stageIDs when sharing the stages
What changes were proposed in this pull request?
Move the currentStageId counter from AdaptiveSparkPlanExec to AdativeExecutionContext.
Why are the changes needed?
The counter is initialized in the constructor of AdaptiveSparkPlanExec as
private var currentStageId = 0
but the previous stages encountered in the subplans and cached in stageCache field of AdaptiveExecutionContext are bound to clash with IDs generated in the current AdaptiveSparkPlanExec.
As of now in the stock spark code, those Ids are not used for lookups ( instead its the canonicalized plans which are used), so there are no issues. ( atleast there are no failing tests and possibly no scope of bug).
May be to make the code safer for future , the currentStageId should be moved as a var field in AdaptiveExecutionContext , to guarantee uniqueness among all the stages seen within an AdaptiveExecutionContext.
Does this PR introduce any user-facing change?
No
How was this patch tested?
Existing tests passing should be sufficient, though will write a dedicated unit test.
Was this patch authored or co-authored using generative AI tooling?
No