viirya opened a new pull request, #56173:
URL: https://github.com/apache/spark/pull/56173

   ### What changes were proposed in this pull request?
   
   Reduce duplication between Arrow and Pandas sibling mixins in 
`python/benchmarks/bench_eval_type.py` by making the Pandas variant subclass 
the Arrow variant, mirroring the existing iter-subclasses-noniter pattern. 
Applies to two pairs:
   
   - `_ScalarPandasBenchMixin` now subclasses `_ScalarArrowBenchMixin`
   - `_GroupedAggPandasBenchMixin` now subclasses `_GroupedAggArrowBenchMixin`
   
   The shared `_build_scenario` and `_write_scenario` are pulled up into the 
Arrow base, with the eval type parameterized via the `_eval_type` class 
attribute (the Scalar pair already used this; this PR extends the same pattern 
to GroupedAgg). `_build_scenario` is converted from `@staticmethod` to 
`@classmethod` so subclasses read their own `_scenario_configs`.
   
   As a follow-on benefit, `_GroupedAggArrowIterBenchMixin` (already a subclass 
of the Arrow base) drops its now-redundant copy of `_write_scenario`.
   
   Net diff: +27 / -102 lines.
   
   ### Why are the changes needed?
   
   Before: each sibling pair had two near-identical `_write_scenario` bodies, 
differing only in the hard-coded `PythonEvalType.SQL_...` constant and the UDF 
set. Any change to the protocol-writing logic (runner_conf, eval_conf, payload 
framing) had to be applied in lock-step across both sibling halves -- a known 
footgun. The pattern already used by the iter subclasses (override `_eval_type` 
+ `_udfs`, inherit everything else) generalizes cleanly to the Arrow/Pandas 
axis.
   
   The Window and CogroupedMap pairs are intentionally left out of this PR to 
avoid conflicting with two in-flight PRs (#56167 makes the Window Arrow mixin 
lazy; #56171 renames `wide_values` to `wide_cols` in the Cogroup pair). Both 
pairs can be folded into the same base-class pattern in a follow-up once those 
land.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No. Test-only change in the benchmark module.
   
   ### How was this patch tested?
   
   - Structural: confirmed `_eval_type` resolves correctly via MRO for all 
seven affected mixins (Scalar Arrow / Arrow-Iter / Pandas / Pandas-Iter, 
GroupedAgg Arrow / Arrow-Iter / Pandas).
   - Confirmed `_ScalarPandasBenchMixin._scenario_configs` still holds the 
pandas-sized row counts (1M `pure_ints`), not the Arrow base's 5M -- the main 
MRO-resolution risk of switching `_build_scenario` to `@classmethod`.
   - Ran `setup` + `time_worker` end-to-end for all 7 `*TimeBench` classes 
(including both UDF arities for the GroupedAgg variants).
   - Ran `peakmem_worker` for one bench class per pair.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Yes. Generated-by: Claude Code (claude-opus-4-7)


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