andygrove opened a new issue, #26307: URL: https://github.com/apache/datafusion/issues/26307
### Is your feature request related to a problem or challenge? [`width_bucket_interval_mdn_exact` (spark/src/function/math/width_bucket.rs#L300-L431)](https://github.com/apache/datafusion/blob/0d79252f61bd8777990b2749c216ffd07079c30d/datafusion/spark/src/function/math/width_bucket.rs#L300-L431) contains two near-identical blocks, "only month" (about L330-L366) and "months equals" (about L368-L424). Each repeats: - the ascending/descending out-of-range checks (bucket `0` or `num_buckets + 1`), - the bucket-width computation with its zero / non-finite null guard, - the floor-plus-one bucket clamp. They differ only in how `x`, `l` and `h` are projected to `f64` (months vs. day/nanosecond offset relative to `l`). Duplicated numeric edge-case handling like this is where a boundary fix ends up in only one copy. ### Describe the solution you'd like Extract `fn bucket_from_f64(x: f64, l: f64, h: f64, num_buckets: i64, ascending: bool) -> Option<i64>` (returning `None` for null). Each branch then only computes its projected `(x, l, h)` and calls it. Optionally move the per-row body into a helper returning `Option<i64>` so the `continue` chains disappear. The existing width_bucket tests cover the behaviour. ### Describe alternatives you've considered None. ### Additional context This is small and self-contained, a good first issue. Line references are pinned to commit 0d79252f61bd. -- 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]
