niebayes opened a new issue, #25314:
URL: https://github.com/apache/datafusion/issues/25314
## Problem
`date_bin(interval, ts)` is the standard time-series bucketing function
(`GROUP BY date_bin(INTERVAL '1 hour', ts)`). Time-based interval strides
(`INTERVAL '1 hour'`, `'1 day'`, `'1 minute'`, ...) all carry `months == 0`
and take the nanosecond-stride path, which is the overwhelmingly common case
for time-series workloads.
That path processes each value through a per-row hot loop with:
- an indirect call through a function pointer (`BinFunction`),
- a chain of checked arithmetic (`checked_mul`/`checked_sub`/`checked_rem`/
`checked_add`) with error closures,
- a `Result -> Option` conversion per value.
None of this is needed: for a positive nanosecond stride the whole
computation
is equivalent to `bin = origin + floor((value*scale -
origin)/stride)*stride`,
i.e. a few plain integer ops.
## Proposal
Add a vectorized fast path for the positive nanosecond-stride case: a single
infallible pass of plain integer arithmetic, guarded by a whole-array
min/max safety check (with a margin covering `origin`/`stride`), falling back
to the existing per-value path for pathological inputs / month strides /
TIME types.
--
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]