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

   ### What changes were proposed in this pull request?
   
   `WidthBucket.doGenCode` emitted two separate static calls — 
`WidthBucket.isNull(...)` for the null check, then 
`WidthBucket.computeBucketNumberNotNull(...)` for the value — which duplicates 
the null/value split in the generated Java. The interpreted path 
(`nullSafeEval`) already goes through a single helper, 
`WidthBucket.computeBucketNumber`, which returns `null` when the bucket is out 
of range and the bucket number otherwise.
   
   This PR routes codegen through that same helper: the generated code calls 
`computeBucketNumber` once, null-checks the boxed result, and assigns it. 
`isNull` and `computeBucketNumberNotNull` are no longer called from generated 
code, so they are made `private`.
   
   ### Why are the changes needed?
   
   It drops one `invokestatic` and one constant-pool method reference at every 
`width_bucket` call site, and lets eval and codegen share one entry point 
instead of keeping two parallel paths in sync. Part of SPARK-56908.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No.
   
   ### How was this patch tested?
   
   Existing `MathExpressionsSuite` `width_bucket` tests. `checkEvaluation` 
exercises both the interpreted and generated paths with whole-stage codegen on 
and off, covering the null cases (`num_bucket <= 0`, `Long.MaxValue`, `NaN`, 
`min == max`, infinite bounds) and the year-month / day-time interval inputs.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code (Claude Opus 4.8)
   


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