viirya opened a new pull request, #60538:
URL: https://github.com/apache/spark/pull/60538
### What changes were proposed in this pull request?
SPARK-61661, SPARK-61666 and SPARK-61668 removed
`ctx.addReferenceObj("plan", this)` from the generated code of
`HashAggregateExec`, `SortExec`, `SortMergeJoinExec`, `SortMergeAsOfJoinExec`
and `ShuffledHashJoinExec`, so a task no longer deserializes the plan subtree
under the operator. Each added a test for its own operators.
This PR adds one test in `WholeStageCodegenSuite` that covers every
whole-stage codegen stage. It runs queries over the operators that generate
code (hash aggregates with and without fast hash maps and adaptive partial
aggregation, distinct and filtered aggregates, sort aggregates, sort, sort
merge / shuffled hash / broadcast hash joins of each join type including
existence joins, broadcast nested loop and broadcast range joins, the as-of
join, expand, generate, window, limit, sample, union, object operators,
subqueries, parquet and cached table scans, and `MergeRows`), with AQE on and
off and `spark.sql.execution.usePartitionEvaluator` on and off. For every
`WholeStageCodegenExec` in the final plan, including those in adaptive query
stages, cached plans and subqueries, it asserts that the RDD the stage adds on
top of its input RDDs serializes no `SparkPlan` (with the existing
`serializedPlanNodes` helper). Each case also asserts that its target operator
is in a codegen stage, so
a planner change cannot make it pass vacuously.
The plan walking helpers that the SPARK-61666 and SPARK-61668 tests defined
locally are moved to the suite and shared.
### Why are the changes needed?
The operator-specific tests only catch a regression in the operators they
cover. A plan node referenced from the generated code of any operator, existing
or new, is serialized into every task of its stage and drags its child subtree,
through the exchanges below, along with it. This test catches that for any
operator the queries cover.
### Does this PR introduce _any_ user-facing change?
No. Test only.
### How was this patch tested?
`build/sbt 'sql/testOnly *WholeStageCodegenSuite'` passes. Adding
`ctx.addReferenceObj("plan", this)` to `ExpandExec.doProduce` makes the new
test fail with `List(Expand, Project, Range, HashAggregate, WholeStageCodegen
(1))`.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 5.5)
This pull request and its description were written by Isaac.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]