xudong963 opened a new issue, #28010:
URL: https://github.com/apache/datafusion/issues/28010

   ### Is your feature request related to a problem or challenge?
   
   #27883 speeds up `date_trunc` on timezone-aware timestamps at `hour` and 
coarser granularities. It works out where a zone's UTC offset is constant and 
truncates with integer arithmetic within those ranges. To find them, it scans 
each zone's offset transitions between 1800 and 2200 the first time the zone is 
used, which takes 0.6–4.6 ms. It then keeps the result in a process-wide cache 
in `datafusion/functions/src/datetime/utc_offsets.rs`, with at most one entry 
per tz database name.
   
   The scan and the cache only exist because chrono-tz doesn't expose its 
transitions. chrono and chrono-tz are also both flagged as unmaintained 
(RUSTSEC-2026-0543, RUSTSEC-2026-0555).
   
   ### Describe the solution you'd like
   
   Once arrow's `Tz` is backed by jiff (apache/arrow-rs#9183, tracked here in 
#23568), get the offset ranges from arrow and delete the scan and the global 
cache. That could be jiff's `TimeZone::following` / `preceding`, or an arrow 
API that returns, for an instant, its offset and the start and end of the range 
where that offset applies.
   
   Two requirements:
   
   - Both ends of the range are needed. Most of the speedup comes from 
replacing chrono's per-value work with arithmetic: even on random input, `hour` 
in New York goes from 158 µs to 11 µs per 1000 values. The range bounds tell 
the kernel where that arithmetic is exact.
   - The ranges must come from the same tz database that arrow uses for casts 
and for `date_trunc`'s chrono fallback. Otherwise results can disagree after a 
zone changes its rules.
   
   ### Describe alternatives you've considered
   
   Calling jiff directly from DataFusion now. jiff reads the system tz database 
or its own bundled copy, while arrow's `Tz` uses the copy compiled into 
chrono-tz. When the two versions differ, `date_trunc` would disagree with casts 
and with its own chrono fallback.
   
   ### Additional context
   
   - Raised by @mhilton in the #27883 review.
   - #27732 uses the same ranges to keep `date_trunc` output ordered for 
timezone-aware timestamps.
   
   ### Willingness to contribute
   
   I plan to contribute to this feature independently
   


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