Skip to content

[SPARK-59160][SQL]. Move the currentStageID counter to AdaptiveExecutionCont… - #58459

Open
ahshahid wants to merge 4 commits into
apache:masterfrom
ahshahid:SPARK-59160
Open

[SPARK-59160][SQL]. Move the currentStageID counter to AdaptiveExecutionCont…#58459
ahshahid wants to merge 4 commits into
apache:masterfrom
ahshahid:SPARK-59160

Conversation

@ahshahid

@ahshahid ahshahid commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

…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

…ext to avoid clash of stageIDs when sharing the stages
@ahshahid
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
ahshahid marked this pull request as ready for review September 2, 2026 07:53
@ahshahid ahshahid changed the title [WIP][SPARK-59160][SQL]. Move the currentStageID counter to AdaptiveExecutionCont… [SPARK-59160][SQL]. Move the currentStageID counter to AdaptiveExecutionCont… Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant