Skip to content

Replace date_trunc's cached timezone transition scan with arrow's Tz once it is backed by jiff #28010

Todo

Description

@xudong963

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

Willingness to contribute

I plan to contribute to this feature independently

Activity

  1. added
    enhancement
    on Dec 4, 2026
  2. self-assigned this
    on Dec 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions