dongjoon-hyun opened a new pull request, #60258:
URL: https://github.com/apache/spark/pull/60258

   ### What changes were proposed in this pull request?
   
   This PR adds two cases to `WideSchemaBenchmark` after `optimize large 
select`. Like that case, each iteration builds a new DataFrame and calls 
`queryExecution.optimizedPlan`, with 100, 1,000 and 10,000 columns.
   
   - `optimize large union`: `groupBy("a_1").count()` over the `union` of two 
projections with N aliases each (`id + i as a_i`).
   - `optimize large cube`: `cube("g_1", "g_2", "g_3")` with a `sum` of each of 
the other N columns of a cached DataFrame.
   
   Each case reaches a `ColumnPruning` case whose cost grows with the square of 
the number of columns.
   
   - `Union`: for the `Aggregate`, `ColumnPruning` adds a `Project` over the 
`Union` and prunes the children in the same pass. The `Project(_, Union)` case 
evaluates `firstChild.output(i)` for each column of each child, and 
`Project.output` builds a new N-element `Seq` on every call. A plain `select` 
does not reach this case, because `PushProjectionThroughUnion` pushes the 
`Project` into the children first.
   - `Expand`: the `Expand` of `CUBE` outputs every input column. For the 
`Aggregate`, `ColumnPruning` drops the original grouping columns and keeps the 
N summed columns. For each element of each projection, the `Project(_, Expand)` 
case looks up the matching `Expand` output attribute in the kept output with a 
linear `Seq.contains`.
   
   ### Why are the changes needed?
   
   To measure the time to analyze and optimize wide `Union` and `CUBE` queries. 
#60254 (SPARK-61277) and #60255 (SPARK-61278) reduce the `ColumnPruning` part 
of this time. No existing benchmark covers these plans: `optimize large select` 
has neither operator, and `ExpandBenchmark` and the `cube` case of 
`AggregateBenchmark` measure execution.
   
   Local results (Apple M3 Max, JDK 21, best time in ms):
   
   | Case | Columns | master | with #60254 and #60255 |
   |---|---:|---:|---:|
   | `optimize large union` | 100 | 3 | 2 |
   | | 1,000 | 68 | 17 |
   | | 10,000 | 6,205 | 239 |
   | `optimize large cube` | 100 | 8 | 7 |
   | | 1,000 | 106 | 92 |
   | | 10,000 | 5,034 | 3,639 |
   
   ### Does this PR introduce _any_ user-facing change?
   
   No. This is a test-only change to a benchmark class.
   
   ### How was this patch tested?
   
   Ran the two new sections locally on master and with both fixes applied (the 
table above).
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Opus 5.5
   


-- 
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]

Reply via email to