Skip to content

feat: add jiff feature to resolve named timezones - #11482

Queued
andygrove wants to merge 18 commits into
apache:mainfrom
andygrove:jiff-named-timezones
Queued

andygrove wants to merge 18 commits into
apache:mainfrom
andygrove:jiff-named-timezones

Conversation

@andygrove

@andygrove andygrove commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Which issue does this PR close?

Rationale for this change

chrono-tz precomputes each zone's transitions up to 2099 and keeps the last offset for every later instant. jiff applies the zone's POSIX TZ rule to any instant, as java.time and libc do. So local 2300-07-01 12:00:00 in America/Los_Angeles is PDT (UTC-7) in Spark and jiff but PST (UTC-8) through arrow_array::timezone::Tz today, and Australia/Sydney stays on daylight time all year from 2100.

As suggested on #9183, this adds jiff alongside chrono-tz as an opt-in feature, so downstream projects can try it before chrono-tz is dropped. Only the engine behind Tz changes. Tz still implements chrono's TimeZone, is still Copy, and accepts the same names with the same Display, Debug and error output.

What changes are included in this PR?

  • arrow-array gets a jiff feature, forwarded by arrow, using jiff 1.0 and jiff-tzdb 1.0. If both chrono-tz and jiff are enabled, jiff is used. Because Cargo unifies features, enabling jiff anywhere in a build changes named timezones for every crate in it.
  • Zones come only from the database compiled into jiff-tzdb, never the host's zoneinfo, so results are deterministic as with chrono-tz. Names must match exactly, as with chrono-tz, and Factory is rejected, so both features accept the same set.
  • Tz holds a 'static reference into a table with one lazily resolved slot per bundled name. Memory is bounded by the database and lookups take no lock.
  • Gaps, folds, offset_from_local_date and GapInfo behave as with chrono-tz. Instants outside jiff's years -9999 to 9999 take the nearest covered offset, because chrono's offset_from_utc_datetime cannot fail.
  • New timezone::tzdb_version() reports the bundled IANA release. chrono-tz 0.10.4 bundles 2025b and jiff-tzdb 1.0.0 bundles 2026f, so the engines also differ before 2100 wherever the database changed.
  • CI tests arrow, arrow-cast, arrow-csv and arrow-json with jiff, checks arrow-array with only jiff, builds wasm32 with jiff, and tests and lints arrow-array with chrono-tz alone, since --all-features now selects jiff.

Are these changes tested?

  • New unit tests cover DST transitions from UTC and from local time, gaps and folds, every bundled name, rejected names, daylight saving in 2100, 2300 and 9999 in both hemispheres, gaps, folds and GapInfo after 2099, and clamping at both ends of jiff's range.
  • Existing tests gated on chrono-tz, including the arrow integration tests and the GapInfo tests, now also run with jiff.
  • With both features enabled, tests compare the engines directly: names, UTC and local offsets, and gaps, weekly from 1900 to 2099 and on each side of every transition. Zones that differ only because of the tzdb releases are listed, and a failure prints both releases.

Benchmarks

arrow/benches/named_timezone.rs is new. It covers parsing, offset lookups from UTC and local time, date_part(Hour) and a cast to string, over three ranges. Before 2038 both engines read a transition table. From 2038 to 2100 jiff evaluates the POSIX rule while chrono-tz still reads its table, with the same results. After 2100 the results differ.

Results on an AMD Ryzen 9 7950X3D, pinned to one core, comparing --features chrono-tz,jiff against --features chrono-tz:

Before 2038, LA and London Before 2038, UTC and Tokyo After 2038, LA and London
offset lookups 7% to 17% faster 8% to 55% faster 1.9x to 2.4x slower
date_part(Hour) within 1% 9% to 15% faster 55% to 66% slower
cast to string 9% to 10% slower 2% to 4% faster 21% to 26% slower

Parsing a name takes 7 to 8 ns, down from 12 to 14 ns. Zones without daylight saving are unaffected by the range.

The cast is slower before 2038 even though its lookup is faster. Shrinking Tz to 8 bytes did not help, and neither did aligning every function to 64 bytes. A profile puts the extra time in chrono's write_rfc3339, which runs the same code with either engine, and the cause is not yet known.

Full results (median time per iteration)
benchmark chrono-tz jiff change
cast_timestamp_to_utf8/128K/1970_to_2038/America/Los_Angeles 11.77 ms 12.89 ms +9%
cast_timestamp_to_utf8/128K/1970_to_2038/Asia/Tokyo 11.02 ms 10.60 ms -4%
cast_timestamp_to_utf8/128K/1970_to_2038/Europe/London 11.36 ms 12.55 ms +10%
cast_timestamp_to_utf8/128K/1970_to_2038/UTC 10.15 ms 9.91 ms -2%
cast_timestamp_to_utf8/128K/2038_to_2100/America/Los_Angeles 11.89 ms 14.52 ms +22%
cast_timestamp_to_utf8/128K/2038_to_2100/Asia/Tokyo 11.09 ms 10.61 ms -4%
cast_timestamp_to_utf8/128K/2038_to_2100/Europe/London 11.45 ms 14.33 ms +25%
cast_timestamp_to_utf8/128K/2038_to_2100/UTC 10.22 ms 9.86 ms -4%
cast_timestamp_to_utf8/128K/2100_to_2300/America/Los_Angeles 12.03 ms 14.56 ms +21%
cast_timestamp_to_utf8/128K/2100_to_2300/Asia/Tokyo 11.11 ms 10.60 ms -5%
cast_timestamp_to_utf8/128K/2100_to_2300/Europe/London 11.29 ms 14.29 ms +26%
cast_timestamp_to_utf8/128K/2100_to_2300/UTC 10.06 ms 9.88 ms -2%
date_part_hour/1M/1970_to_2038/America/Los_Angeles 29.61 ms 29.77 ms +1%
date_part_hour/1M/1970_to_2038/Asia/Tokyo 24.81 ms 22.69 ms -9%
date_part_hour/1M/1970_to_2038/Europe/London 29.66 ms 29.61 ms -0%
date_part_hour/1M/1970_to_2038/UTC 22.81 ms 19.50 ms -15%
date_part_hour/1M/2038_to_2100/America/Los_Angeles 30.34 ms 49.85 ms +64%
date_part_hour/1M/2038_to_2100/Asia/Tokyo 24.89 ms 22.64 ms -9%
date_part_hour/1M/2038_to_2100/Europe/London 30.31 ms 50.34 ms +66%
date_part_hour/1M/2038_to_2100/UTC 22.75 ms 19.47 ms -14%
date_part_hour/1M/2100_to_2300/America/Los_Angeles 32.24 ms 49.84 ms +55%
date_part_hour/1M/2100_to_2300/Asia/Tokyo 24.75 ms 22.65 ms -8%
date_part_hour/1M/2100_to_2300/Europe/London 31.80 ms 50.64 ms +59%
date_part_hour/1M/2100_to_2300/UTC 22.81 ms 19.50 ms -15%
tz_offset_from_local_datetime/1970_to_2038/America/Los_Angeles 154.25 µs 142.72 µs -7%
tz_offset_from_local_datetime/1970_to_2038/Asia/Tokyo 130.27 µs 120.38 µs -8%
tz_offset_from_local_datetime/1970_to_2038/Europe/London 156.78 µs 143.35 µs -9%
tz_offset_from_local_datetime/1970_to_2038/UTC 136.35 µs 64.63 µs -53%
tz_offset_from_local_datetime/2038_to_2100/America/Los_Angeles 157.89 µs 383.09 µs +143%
tz_offset_from_local_datetime/2038_to_2100/Asia/Tokyo 130.43 µs 119.94 µs -8%
tz_offset_from_local_datetime/2038_to_2100/Europe/London 160.83 µs 382.98 µs +138%
tz_offset_from_local_datetime/2038_to_2100/UTC 136.29 µs 64.63 µs -53%
tz_offset_from_local_datetime/2100_to_2300/America/Los_Angeles 168.53 µs 386.77 µs +129%
tz_offset_from_local_datetime/2100_to_2300/Asia/Tokyo 130.32 µs 120.73 µs -7%
tz_offset_from_local_datetime/2100_to_2300/Europe/London 167.62 µs 385.93 µs +130%
tz_offset_from_local_datetime/2100_to_2300/UTC 136.34 µs 64.63 µs -53%
tz_offset_from_utc_datetime/1970_to_2038/America/Los_Angeles 106.60 µs 89.01 µs -17%
tz_offset_from_utc_datetime/1970_to_2038/Asia/Tokyo 78.06 µs 53.25 µs -32%
tz_offset_from_utc_datetime/1970_to_2038/Europe/London 108.35 µs 89.52 µs -17%
tz_offset_from_utc_datetime/1970_to_2038/UTC 67.53 µs 30.25 µs -55%
tz_offset_from_utc_datetime/2038_to_2100/America/Los_Angeles 110.76 µs 238.38 µs +115%
tz_offset_from_utc_datetime/2038_to_2100/Asia/Tokyo 78.11 µs 53.08 µs -32%
tz_offset_from_utc_datetime/2038_to_2100/Europe/London 113.60 µs 244.64 µs +115%
tz_offset_from_utc_datetime/2038_to_2100/UTC 67.47 µs 30.23 µs -55%
tz_offset_from_utc_datetime/2100_to_2300/America/Los_Angeles 124.92 µs 240.12 µs +92%
tz_offset_from_utc_datetime/2100_to_2300/Asia/Tokyo 78.06 µs 53.15 µs -32%
tz_offset_from_utc_datetime/2100_to_2300/Europe/London 125.06 µs 245.87 µs +97%
tz_offset_from_utc_datetime/2100_to_2300/UTC 67.47 µs 30.19 µs -55%
tz_parse/America/Los_Angeles 14.00 ns 8.10 ns -42%
tz_parse/Asia/Tokyo 12.35 ns 7.38 ns -40%
tz_parse/Europe/London 12.83 ns 7.41 ns -42%
tz_parse/UTC 11.93 ns 7.52 ns -37%

Offset lookup rows are for 8192 instants per iteration.

Are there any significant user-facing changes?

No. The feature is opt-in, and timezone::tzdb_version() is the only new public item.

Follow-ups, before jiff could become the default in a major release:

  • Remove the post-2038 cost in DST zones, for example with a per-zone transition table built in arrow up to a later horizon, as prototyped in review.
  • Find the cause of the slower cast before 2038.

AI usage disclosure

The code, tests, benchmarks and this description were written with an AI assistant (Claude Code).

@andygrove
andygrove marked this pull request as ready for review October 9, 2026 20:23

@comphead comphead left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @andygrove I'll check this later, the PR goes into right direction, having jiff as separate feature

@viirya viirya left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. Swapping only the engine behind Tz is a nice way to stage the migration, and the local-time mapping (gap → None, fold order, offset_from_local_date) matches chrono-tz exactly. I left inline comments; the two I'd consider blocking are the host-zoneinfo dependence and the unbounded interning cache.

One more thing that doesn't fit a single line: results differ before 2100 too, because the bundled tzdb versions differ (chrono-tz 0.10.4 bundles 2025b, jiff-tzdb 0.1.8 bundles 2026c). Sampling every 6h over 1900–2100, 13 zones differ, e.g. America/Vancouver and America/Edmonton from 2026-11, Africa/Casablanca from 2026-09, America/Tijuana in 1953, and Europe/Chisinau in 2022. Newer data is fine, but it's worth documenting. Downstreams that report the tzdb version will report the wrong one once jiff is on (Comet reports chrono_tz::IANA_TZDB_VERSION to the JVM). Would a timezone::tzdb_version() helper make sense? Also, since jiff overrides chrono-tz for the whole build, the feature docs should say that enabling it anywhere in the graph changes timezone semantics everywhere.

Comment thread arrow-array/src/timezone.rs Outdated
return Ok(tz);
}
// Same message as the chrono-tz path, so callers see one error regardless of feature
let tz = JiffTimeZone::get(name).map_err(|_| {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This goes through jiff's global db(). If anything else in the dependency graph enables jiff's default features (for example, opendal-core already depends on jiff in this workspace's lockfile), jiff reads /usr/share/zoneinfo / $TZDIR before the bundle. With TZDIR pointing at a directory whose America/Los_Angeles is a copy of Asia/Tokyo, Tz returned +09:00, and a name only present there (Fake_Zone) parsed successfully. Could this use jiff::tz::TimeZoneDatabase::bundled() explicitly, held in a static?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I reproduced it with jiff's default features enabled alongside and TZDIR pointing at a fake directory. America/Los_Angeles came back as +09:00, Fake_Zone parsed, and US/Pacific failed: jiff uses the zoneinfo database in place of the bundle, not just ahead of it. Fixed in dafbd24. Names are now resolved through TimeZoneDatabase::bundled(), held in a static. With the same setup, LA is back to -08:00, Fake_Zone is rejected, and US/Pacific resolves from the bundle.

Comment thread arrow-array/src/timezone.rs Outdated
))
})?;
let mut cache = cache.write().unwrap();
Ok(cache.entry(name.into()).or_insert_with(|| {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jiff's lookup is ASCII case-insensitive, but the cache is keyed by the input string, so every casing is resolved and leaked separately. All 4096 case variants of the first 12 chars of america/los_angeles were accepted and leaked. string_to_datetime (arrow-cast/src/parse.rs:221) parses the timezone suffix of each row, so CSV/JSON/cast input can reach this. It's also a behaviour change: chrono-tz's FromStr is case-sensitive, while this accepts utc, america/new_york, Etc/Unknown and Factory, and Display echoes the non-canonical casing. Requiring tz.iana_name() == Some(name) (or keying/displaying by the canonical name) would fix both.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in dafbd24. A name now has to match a bundled name exactly, so utc, america/new_york and Etc/Unknown are rejected, and Display always shows the canonical name. I also reject Factory: it's the only name jiff-tzdb 0.1.8 has that chrono-tz 0.10.4 doesn't, so both features now accept exactly the same names.

I replaced the cache instead of re-keying it. It's now a map built once with a slot per bundled name, each a OnceLock resolved on first use, and Tz points into it. Memory is bounded by the database whatever the input, nothing is leaked, and since the keys never change, parsing takes no lock. With ahash for the lookup (13b9127), parsing a name takes 6–8 ns, against 11–13 ns for chrono-tz.


fn fixed_offset(offset: jiff::tz::Offset) -> FixedOffset {
// Real timezone data never holds an offset of a day or more, so this cannot fail
FixedOffset::east_opt(offset.seconds()).expect("timezone offset within a day")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jiff allows offsets up to ±25:59:59, so this holds for the bundled data but not for an arbitrary TZif file, which can be loaded through the host zoneinfo path above. Using the bundled db explicitly would make the comment true. Otherwise, clamping or returning UTC would be safer than panicking.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that lookups only use the bundled database, the comment holds, and it says so. To check, I walked every transition of all 598 bundled zones through 2200, plus the offsets at jiff's min and max instants. The largest absolute offset is 15:56:08 (Asia/Manila's local mean time before 1845), so the expect can't fire.

Comment thread arrow-array/src/timezone.rs Outdated
.unwrap();
// Falls back to the offset in force at jiff's last covered instant rather than failing
let utc = tz.offset_from_utc_datetime(&far).fix();
assert!(utc.local_minus_utc() == -8 * 60 * 60 || utc.local_minus_utc() == -7 * 60 * 60);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The clamp deterministically gives −08:00 here, since jiff's max timestamp is in December, so the assertion could be exact. On open question 3: offset_from_utc_datetime is infallible, so an "error" would have to be a panic. Clamping seems like the only workable option within the trait.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made it exact in dafbd24 and covered the other end too: year -20000 clamps to Timestamp::MIN and gets LA's local mean time, -07:52:58, on both the UTC and the local path. Agreed on question 3. The trait methods are infallible, so clamping it is, and I've dropped the question from the description.

Comment thread arrow-array/Cargo.toml Outdated
arrow-data = { workspace = true }
chrono = { workspace = true }
chrono-tz = { version = "0.10", optional = true }
# `tzdb-bundle-always` compiles the IANA database into the crate, as chrono-tz does, so results

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only holds if no other crate in the build enables jiff's tzdb-zoneinfo (see the comment on named_tz). The PR description also lists only std + tzdb-bundle-always, while tz-fat and perf-inline are enabled too.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the explicit bundled database the comment holds whatever else is in the build. I reworded it to say so and to note that tz-fat and perf-inline are jiff defaults that speed up offset lookups (dafbd24). I fixed the description too.

Comment thread .github/workflows/arrow.yml Outdated
run: cargo test -p arrow
- name: Test arrow except pyarrow
run: cargo test -p arrow --features=force_validate,prettyprint,ipc_compression,ffi,chrono-tz
- name: Test arrow with named timezones resolved by jiff

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this PR, cargo test -p arrow-array --all-features (line 49) selects jiff, and the other arrow-array steps enable neither feature. The chrono-tz private module and its tests are no longer compiled, run, or linted (clippy also uses --all-features). Could you add a cargo test -p arrow-array --features chrono-tz step and a matching clippy step?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in ee30fb3: cargo test -p arrow-array --features=chrono-tz in the arrow-array test step and cargo clippy -p arrow-array --all-targets --features chrono-tz -- -D warnings in the clippy step.

Comment thread arrow/benches/named_timezone.rs Outdated

const ZONES: [&str; 4] = ["UTC", "America/Los_Angeles", "Europe/London", "Asia/Tokyo"];

/// Instant ranges in microseconds. Fat TZif data, and so jiff's transition tables, stop at 2038;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2038–2100 is still inside chrono-tz's precomputed table: LA offsets match jiff exactly until 2100. So the ~2x there is the cost of jiff evaluating the POSIX rule versus a table lookup, not chrono-tz skipping the rule. That range is a pure slowdown with no correctness gain, which seems worth saying in the description. Also, tz_parse is single-threaded, so it doesn't capture contention on the global RwLock when a timezone is parsed per row.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. Sampling hourly from 2038 to 2100, chrono-tz and jiff agree exactly for all four zones in the bench, so that range is a pure slowdown: jiff evaluating the POSIX rule against chrono-tz reading its table. I fixed the comment and the description, and 1ad49e5 adds a 2100–2300 range, which is where chrono-tz freezes the offset and evaluating the rule changes results. The parse path no longer takes a lock (see the reply on named_tz) and is now faster than chrono-tz's, so there's no contention left for a multithreaded parse bench to show.

@andygrove

Copy link
Copy Markdown
Member Author

Thanks for the careful review, @viirya. Replies are inline. On the points in your summary:

  • dafbd24 adds timezone::tzdb_version(), which returns jiff_tzdb::VERSION with jiff, chrono_tz::IANA_TZDB_VERSION with chrono-tz, and None with neither. jiff doesn't expose the release it bundles, so arrow-array now depends on jiff-tzdb directly. It's the same copy jiff resolves to, so Cargo.lock gains no package.
  • The timezone module docs now describe both features. They say that enabling jiff anywhere in a build changes how every crate in it resolves named timezones, and that the bundled releases differ (2025b and 2026c today), so results can differ before 2100 too. The build-wide note is also in the arrow README and on DataType::Timestamp.

While writing those docs I found a mistake in my description. After 2099, chrono-tz doesn't fall back to standard time; it keeps the offset of its last transition. Southern-hemisphere zones therefore stay on daylight time all year: Australia/Sydney is +11:00 in July 2150. I've corrected the description, and test_dst_applies_after_2099 now checks Sydney as well as LA.

@comphead comphead left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @andygrove. Swapping only the engine behind Tz is a good way to stage the migration, and the follow-ups on @viirya's review resolved the blocking points. I checked out 13b9127 and ran some experiments. Findings and suggestions below, roughly in priority order. I'd like to see 2 to 4 in this PR. The rest can be follow-ups.

What I verified

  • With chrono-tz,jiff, offset_from_local_datetime matches chrono-tz exactly at 30-minute steps over 2000 to 2030 for America/Los_Angeles, Europe/London, Australia/Sydney, Australia/Lord_Howe and America/Sao_Paulo, including gaps and folds.
  • UTC offsets sampled every 3h over 1970 to 2100 differ for 13 zones, all explained by 2025b vs 2026c. This matches @viirya's sample.
  • Name sets are 597 vs 598, and Factory is the only difference.
  • The arrow-cast, arrow-json, arrow-csv and arrow-arith test suites pass with --features arrow-array/jiff.

1. Post-2038 cost in DST zones

On #9183 the bar for the migration was same answers and equal or better performance. Between 2038 and 2100 the ~2x on date_part buys nothing, since both engines agree there. jiff's fat-table horizon is a private const, but arrow can fix this on its own side. I prototyped a lazily built transition table per zone, using TimeZone::following:

// Built once per zone on first use, stored next to `tz` in `NamedTz`
let horizon = Timestamp::from_second(10_413_792_000).unwrap(); // 2300-01-01
let (mut secs, mut offs) = (Vec::new(), Vec::new());
for tr in tz.following(start) {
    if tr.timestamp() > horizon {
        break;
    }
    secs.push(tr.timestamp().as_second());
    offs.push(tr.offset().seconds());
}

// Lookup, with a `#[cold]` fallback to `tz.to_offset` beyond the horizon
match secs.partition_point(|&t| t <= s) {
    0 => before,
    i => offs[i - 1],
}

For LA, London and Sydney that's about 700 transitions, about 8.5 KB per zone, and about 50 µs to build. 1M lookups over 2038 to 2300 took 4 to 5 ms against 18 to 25 ms for to_offset, and sampled offsets matched jiff. This was a rough Instant timing, not criterion. The local path would need the same table read with before/after offsets to find gaps and folds, so it's more work. A follow-up is fine, but I'd want it before jiff becomes the default. It also answers open question 3 without needing changes in jiff.

2. Other crates are not tested with jiff in CI

arrow-cast enables arrow-array/chrono-tz through its dev-dependency, and arrow-cast, arrow-json and arrow-csv never run with jiff. The timestamp parsing and cast tests live there. They pass locally, but nothing guards against regressions. Could you add something like:

cargo test -p arrow-cast --features arrow-array/jiff
cargo test -p arrow-json --features arrow-array/jiff
cargo test -p arrow-csv --features arrow-array/jiff

3. A test comparing the two engines

--features chrono-tz,jiff already compiles both crates, so a #[cfg(all(feature = "chrono-tz", feature = "jiff"))] test can compare them directly:

  • chrono_tz::TZ_VARIANTS names against the bundled names. This also guards the hard-coded "Factory" filter.
  • Offsets from UTC and local time over a sampled range, with an explicit allowlist of the 13 zones known to differ.

That catches silent drift whenever either crate bumps its tzdb.

4. Debug output changed

chrono-tz: Tz(Timezone(America/Los_Angeles))
jiff:      Tz(Timezone(NamedTz { name: "America/Los_Angeles", tz: TimeZone(TZif("America/Los_Angeles")) }))

TzOffset grows the same way. A hand-written Debug for NamedTz that writes only self.name would restore the old output and keep downstream snapshots and error messages stable.

5. Tz doubled in size

Tz went from 8 to 16 bytes and TzOffset from 12 to 24, so DateTime<Tz> grows too. The pre-2038 benchmarks show no cost, so this is optional. A u16 index into a static slice would keep 8 bytes, at the price of a bounds-checked lookup. Either way, a compile-time check would lock in the chosen size:

const _: () = assert!(std::mem::size_of::<Tz>() == 16);

6. tzdb_version depends on Cargo picking a single jiff-tzdb

This holds today because both ask for 0.1.8. If jiff later moves to jiff-tzdb 0.2, the build would carry two copies, and the reported version would silently be wrong. A sturdier option is to build the table directly from jiff_tzdb::available(), jiff_tzdb::get() and TimeZone::tzif():

  • The data and the version come from one crate.
  • The keys can be &'static str, which removes about 600 Box<str> allocations.
  • The tzdb-bundle-always feature is no longer needed.

I haven't checked that TimeZone::tzif builds the 2038 fat table the same way the bundled database does, so treat this as a suggestion to try.

7. Open questions

  1. Bundled as the default makes sense to me. If host zoneinfo becomes an opt-in, the expect in fixed_offset needs revisiting, since arbitrary TZif files can hold offsets up to ±25:59:59.
  2. I'd rather not put jiff behind the existing chrono-tz feature name. The results change for post-2099 instants and for zones updated between 2025b and 2026c, and a feature that stays the same while behaviour changes is easy to miss. Flipping the default in a major release, with a release note, seems safer.
  3. See 1. This can be handled in arrow.

Nits

  • The bench has required-features = ["chrono-tz"], so it can't run with --features jiff alone. Worth a comment, since Cargo has no OR there.
  • For years outside jiff's range, offset_from_local_datetime treats the local datetime as UTC before clamping. Fine, but worth a line in the doc comment.
  • The wasm32 CI job doesn't build with jiff. Adding it to one of the wasm builds would be cheap insurance.
  • Benchmark numbers came from a non-idle laptop. A rerun on an idle machine, or instruction counts, would make the post-2038 comparison easier to trust.

@viirya viirya left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the thorough follow-up, @andygrove. I re-ran my earlier repros against 13b9127. With jiff's default features enabled alongside and TZDIR pointing at a fake zoneinfo, America/Los_Angeles resolves from the bundle and Fake_Zone is rejected. Case variants, utc, Etc/Unknown and Factory are rejected, and every chrono-tz 0.10.4 name parses and round-trips through Display. That resolves everything I raised.

+1 to @comphead's points 2, 4 and 5. At this head Debug still prints the full NamedTz { name, tz: TimeZone(TZif(..)) }, and Tz/TzOffset are 16/24 bytes.

On the engine-comparison test in point 3: the set of zones that differ depends on the exact pair of releases. Resolving fresh today picks jiff-tzdb 0.1.9 (2026e). Against chrono-tz's 2025b, the count over 1900–2100 goes from 13 to 26 zones. So an allowlist will fail on routine tzdb bumps, including lockfile-only dependabot updates. That's probably the point of the test, but printing both releases in the failure message would tell whoever bumps the dependency what to update.

Comment thread arrow-array/Cargo.toml Outdated
jiff = { version = "0.2", default-features = false, features = ["std", "tzdb-bundle-always", "tz-fat", "perf-inline"], optional = true }
# jiff does not report which release of the database it bundles, so `timezone::tzdb_version`
# reads it from jiff-tzdb, which Cargo resolves to the same copy that jiff uses
jiff-tzdb = { version = "0.1.8", optional = true }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This holds today. Both this and jiff 0.2.35 ask for ^0.1.8, and a fresh resolve picks a single jiff-tzdb 0.1.9, with tzdb_version() reporting 2026e to match the data. It would only break if jiff moves to a semver-incompatible jiff-tzdb, as @comphead noted. Building the table from jiff_tzdb directly (see the comment on named_tz) would remove that dependency on Cargo's resolution.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in ecd86af. The data and the reported version now both come from jiff_tzdb, so this no longer depends on Cargo resolving one copy.

Comment thread arrow-array/src/timezone.rs Outdated
.get_key_value(name)
.and_then(|(name, slot)| {
slot.get_or_init(|| {
let tz = bundled_db().get(name).ok()?;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re @comphead's point 6: the bundled database's get is exactly TimeZone::tzif(canonical_name, <jiff_tzdb bytes>) (jiff src/tz/db/bundled/enabled.rs). So jiff_tzdb::get(name) + TimeZone::tzif would produce the same TimeZone, fat table included. One difference to keep if this switches over: before touching TZif data, the bundled get maps UTC to TimeZone::UTC via special_time_zone. A direct construction would turn UTC into a TZif-backed zone, so it should special-case UTC the same way.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in ecd86af, using jiff_tzdb::get and TimeZone::tzif, with UTC mapped to TimeZone::UTC first.

@boring-cyborg boring-cyborg Bot added arrow-core Core crates related to representing arrow data arrow-kernels Crates that transform arrow data (e.g. compute, cast) development-process Internal changes; PRs with this label are excluded from changelog labels Nov 8, 2026
@andygrove

Copy link
Copy Markdown
Member Author

Pushed d7704ad (merge with main) and ecd86af (review changes).

  • 2: CI now runs the arrow-cast, arrow-csv and arrow-json tests with arrow-array/jiff, and the wasm32-unknown-unknown build includes jiff.
  • 3: With both features on, new tests compare the engines' names, UTC and local offsets, and gaps. Offsets and gaps are checked weekly over 1900 to 2099 and on each side of every transition. The allowlist holds the same 13 zones reported above, and failures print both tzdb releases.
  • 4: Debug for Tz and TzOffset matches chrono-tz again, with a test.
  • 5: I kept 16 bytes rather than adding an index lookup on every offset, and added a compile-time assertion for 64-bit targets. wasm32 pointers are smaller, so the sizes differ there.
  • 6: The table is now built from jiff_tzdb directly, with UTC special-cased as in jiff's bundled database. tzdb-bundle-always is gone, and the keys are &'static str.
  • Nits: added the bench comment and the doc comment for local datetimes outside jiff's range.

Merging main also meant implementing GapInfo for jiff. Its tests now run on both engines, and the comparison test checks it against chrono-tz.

The post-2038 cost is still open, as a follow-up before jiff becomes the default. I haven't rerun the benchmarks on an idle machine.

@andygrove
andygrove requested review from comphead and viirya November 8, 2026 16:29
// As jiff's own bundled database does, so that UTC is not backed by TZif data
if name == "UTC" {
return Some(JiffTimeZone::UTC);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That check is needed in jiff because Etc/Unknown isn't in the database, so get() has to handle it first. Here, names are looked up in a table built from jiff_tzdb::available() before bundled_tz is called, so Etc/Unknown is rejected as an invalid timezone and never reaches this function. Adding the check here wouldn't change that.

Rejecting it is intentional for now, because this feature accepts the same names as chrono-tz, which doesn't have Etc/Unknown. test_invalid_timezone covers this. If we want to accept it once jiff becomes the default, it will need a table entry as well as the TimeZone::unknown() special case.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay! Thank you for that additional context.

@andygrove

Copy link
Copy Markdown
Member Author

f0e742b updates the lockfile to jiff 0.2.41 and jiff-tzdb 0.1.9, so CI tests the releases that builds without this lockfile resolve. The bundled database moves to 2026e, and the comparison test's allowlist grows from 13 to 26 zones, as predicted in the review above.

@pierre-warnier pierre-warnier left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran the test matrix and the named_timezone bench for this PR at f0e742b (it still merges cleanly onto main 4f1ed42). I also tried it against jiff 1.0, since #9183 proposes moving to it.

Tests (rustc 1.99.1 from rust-toolchain.toml): all green.

Command Result
cargo test -p arrow --features chrono-tz,jiff / --features chrono-tz 182 / 182 passed
cargo test -p arrow-array --features jiff / --features chrono-tz,jiff 979 / 981 passed, 2 ignored
cargo test -p arrow-cast -p arrow-csv -p arrow-json --features arrow-array/jiff 725 passed
cargo clippy -p arrow-array -p arrow --all-targets --features arrow-array/jiff,arrow/chrono-tz -- -D warnings clean
cargo check -p arrow-array --no-default-features --features jiff ok

jiff 1.0.0 / jiff-tzdb 1.0.0: the PR builds with two small changes, because jiff_tzdb::VERSION is now &'static str instead of Option<&str>. tzdb_version() returns Some(jiff_tzdb::VERSION), and the test message drops .unwrap_or("unknown"). After that, everything above passes except compare_with_chrono_tz::test_same_offsets: tzdb 2026f differs from chrono-tz's 2025b in 23 more zones (America/Sao_Paulo and the other Brazilian zones, America/Havana/Cuba). The allowlist goes from 26 to 49 zones. That is expected data drift, not a bug, but the allowlist will need the update in the rebase. On performance, jiff 1.0 was within noise of 0.2.41 (rows marked † below).

Benchmarks: cargo bench -p arrow --bench named_timezone --features chrono-tz -- --save-baseline chrono, then --features chrono-tz,jiff -- --baseline chrono. Each process was pinned to one P-core (taskset) with criterion --warm-up-time 1 --measurement-time 3, on an i9-14900F running Linux 7.0. The machine is a shared workstation and was not idle (load average 6–18 on 32 threads). I ran the kernel groups twice, in opposite order, and show the spread. Values are the ratio of jiff to chrono-tz medians; below 1 means jiff is faster.

DST zones (America/Los_Angeles, Europe/London):

Bench 1970–2038 2038–2100 2100–2300
tz_offset_from_utc_datetime 0.66–0.84 † 1.90–1.95 † 1.70–1.74
tz_offset_from_local_datetime 0.71–0.82 † 2.14–2.37 † 2.31
date_part_hour/1M 1.09–1.19 † 1.75–2.40 † 1.58–1.64
cast_timestamp_to_utf8/128K 1.05–1.11 † 1.29–1.42 † 1.21–1.26 ‡

Fixed-offset zones (UTC, Asia/Tokyo): 0.30–1.04 on every row and range. tz_parse: 0.68–0.75.
‡ In the first pass, the 2100–2300 kernel groups ran last, during a load spike, and read 1.45–2.01 (cast, all zones) and 1.16 (Tokyo date_part). The rerun gave 1.21–1.26 for DST zones and 0.81–1.02 for fixed-offset zones, so I treat the first pass as noise.

Two observations against the 5% gate proposed on #9183:

  1. After 2038 the cost matches the 1.7–2.4x already reported: offsets come from the POSIX rule instead of a table.
  2. For 1970–2038 in DST zones, the offset lookups are 16–34% faster with jiff, but date_part and cast are still 5–19% slower. This holds in all three runs, on jiff 0.2.41 and 1.0. Both kernels resolve offsets through offset_from_utc_datetime. A variant of the lookup bench with dense input (1 day of instants) is still faster for LA (0.75x), so input locality does not explain it. The cost seems to sit outside the lookup itself, possibly in the copies of the larger TzOffset (24 bytes, holding Tz). That is a guess I have not profiled. It may be worth adding a kernel-level row for 1970–2038 to the gate, since a lookup-only gate would pass today.

Happy to rerun this on each revision.

(Disclosure: I used an AI assistant to run and tabulate these measurements. I reviewed the commands and results.)

Add an opt-in `jiff` feature to arrow-array and arrow that resolves IANA
timezone names with jiff instead of chrono-tz. The public `Tz` type is
unchanged: it still implements chrono's `TimeZone`, is still `Copy`, and
prints and errors as before.

chrono-tz precomputes each zone's transitions and applies the standard
offset after the last one, around 2099. jiff applies the zone's POSIX TZ
rule indefinitely, as java.time and libc do, so daylight saving keeps
being applied to far-future instants.
Add a bench that parses named zones, looks up offsets from UTC and local
datetimes, and runs date_part and a timestamp to string cast over named
zone arrays, split into instants before and after 2038 because fat TZif
tables end there and later instants take jiff's POSIX rule path.

Enable jiff's tz-fat and perf-inline features, which its defaults include.
main added timezone::GapInfo, which each timezone engine has to provide. Implement it for jiff and move the tests for named zones out of the chrono-tz module so that they run against both.
- Run the arrow-cast, arrow-csv and arrow-json tests with jiff in CI, and
  build jiff for wasm32.
- Compare the chrono-tz and jiff engines directly over names, offsets and
  gaps, printing both tzdb releases on failure.
- Restore the short Debug output for Tz and TzOffset.
- Assert the size of Tz and TzOffset on 64-bit targets.
- Build timezones directly from jiff-tzdb, so tzdb_version always
  describes the data in use and table keys need no allocation.
Test against the releases that builds without this lockfile resolve. The
bundled database moves to 2026e, so the list of zones that differ from
chrono-tz's 2025b grows from 13 to 26.
jiff-tzdb 1.0 always records its tzdb release, so `jiff_tzdb::VERSION` is no longer an `Option`. It bundles 2026f, which changes Cuba's 2026 fall back and Brazil's 1965 and 1966 DST ends, so those zones join the list that differs from chrono-tz's 2025b.
@andygrove
andygrove force-pushed the jiff-named-timezones branch from f0e742b to b5d5f87 Compare November 17, 2026 13:11
@andygrove

Copy link
Copy Markdown
Member Author

Rebased on main and moved to jiff 1.0 in b5d5f87.

  • jiff 1.0 commits to a stable 1.x API, so depending on it no longer ties arrow-array to a 0.x release.
  • jiff_tzdb::VERSION is no longer an Option in 1.0, so tzdb_version() with jiff now always returns Some.
  • jiff-tzdb 1.0.0 bundles 2026f. That release keeps Cuba on -04 through 2027-11-07 and corrects Brazil's DST ends in 1965 and 1966. The comparison test's allowlist grows from 26 to 49 zones, all of them Cuba or Brazil zones.
  • The main merge is gone from the history. The GapInfo work it carried is now its own commit, 18afd6b.

@andygrove

Copy link
Copy Markdown
Member Author

I ran the test matrix and the named_timezone bench for this PR at f0e742b (it still merges cleanly onto main 4f1ed42). I also tried it against jiff 1.0, since #9183 proposes moving to it.

Tests (rustc 1.99.1 from rust-toolchain.toml): all green.

Command Result
cargo test -p arrow --features chrono-tz,jiff / --features chrono-tz 182 / 182 passed
cargo test -p arrow-array --features jiff / --features chrono-tz,jiff 979 / 981 passed, 2 ignored
cargo test -p arrow-cast -p arrow-csv -p arrow-json --features arrow-array/jiff 725 passed
cargo clippy -p arrow-array -p arrow --all-targets --features arrow-array/jiff,arrow/chrono-tz -- -D warnings clean
cargo check -p arrow-array --no-default-features --features jiff ok
jiff 1.0.0 / jiff-tzdb 1.0.0: the PR builds with two small changes, because jiff_tzdb::VERSION is now &'static str instead of Option<&str>. tzdb_version() returns Some(jiff_tzdb::VERSION), and the test message drops .unwrap_or("unknown"). After that, everything above passes except compare_with_chrono_tz::test_same_offsets: tzdb 2026f differs from chrono-tz's 2025b in 23 more zones (America/Sao_Paulo and the other Brazilian zones, America/Havana/Cuba). The allowlist goes from 26 to 49 zones. That is expected data drift, not a bug, but the allowlist will need the update in the rebase. On performance, jiff 1.0 was within noise of 0.2.41 (rows marked † below).

Benchmarks: cargo bench -p arrow --bench named_timezone --features chrono-tz -- --save-baseline chrono, then --features chrono-tz,jiff -- --baseline chrono. Each process was pinned to one P-core (taskset) with criterion --warm-up-time 1 --measurement-time 3, on an i9-14900F running Linux 7.0. The machine is a shared workstation and was not idle (load average 6–18 on 32 threads). I ran the kernel groups twice, in opposite order, and show the spread. Values are the ratio of jiff to chrono-tz medians; below 1 means jiff is faster.

DST zones (America/Los_Angeles, Europe/London):

Bench 1970–2038 2038–2100 2100–2300
tz_offset_from_utc_datetime 0.66–0.84 † 1.90–1.95 † 1.70–1.74
tz_offset_from_local_datetime 0.71–0.82 † 2.14–2.37 † 2.31
date_part_hour/1M 1.09–1.19 † 1.75–2.40 † 1.58–1.64
cast_timestamp_to_utf8/128K 1.05–1.11 † 1.29–1.42 † 1.21–1.26 ‡
Fixed-offset zones (UTC, Asia/Tokyo): 0.30–1.04 on every row and range. tz_parse: 0.68–0.75. ‡ In the first pass, the 2100–2300 kernel groups ran last, during a load spike, and read 1.45–2.01 (cast, all zones) and 1.16 (Tokyo date_part). The rerun gave 1.21–1.26 for DST zones and 0.81–1.02 for fixed-offset zones, so I treat the first pass as noise.

Two observations against the 5% gate proposed on #9183:

  1. After 2038 the cost matches the 1.7–2.4x already reported: offsets come from the POSIX rule instead of a table.
  2. For 1970–2038 in DST zones, the offset lookups are 16–34% faster with jiff, but date_part and cast are still 5–19% slower. This holds in all three runs, on jiff 0.2.41 and 1.0. Both kernels resolve offsets through offset_from_utc_datetime. A variant of the lookup bench with dense input (1 day of instants) is still faster for LA (0.75x), so input locality does not explain it. The cost seems to sit outside the lookup itself, possibly in the copies of the larger TzOffset (24 bytes, holding Tz). That is a guess I have not profiled. It may be worth adding a kernel-level row for 1970–2038 to the gate, since a lookup-only gate would pass today.

Happy to rerun this on each revision.

(Disclosure: I used an AI assistant to run and tabulate these measurements. I reviewed the commands and results.)

Thanks for this. I am running fresh benchmarks now and will. update PR description when done. Will take an hour or so.

@andygrove

Copy link
Copy Markdown
Member Author

Thanks for the measurements, @pierre-warnier. b5d5f87 makes the same jiff 1.0 changes you describe, including the allowlist growing to 49 zones.

I reran the bench on an AMD Ryzen 9 7950X3D, pinned to one core, and updated the Benchmarks section of the description with the results.

  • date_part before 2038 is within 1% in America/Los_Angeles and Europe/London here, so the slowdown you saw on the i9-14900F does not reproduce on this machine.
  • The string cast before 2038 is 9% to 10% slower in those zones, so that part does reproduce.

On the TzOffset size guess, I tried an 8-byte Tz and a 12-byte TzOffset, the same sizes as with chrono-tz, using a u16 index into the zone table. It measured the same, and it made the cast in Asia/Tokyo 20% slower, so I have not pushed it. Aligning every function to 64 bytes in both builds did not change the result either.

A profile puts all of the extra time in chrono's write_rfc3339, which runs the same code on the same inputs with either engine. The jiff build runs about 10% fewer instructions per row, with fewer branch misses, but at a lower IPC. I have not found the cause yet.

I agree the gate on #9183 should include kernel-level rows for 1970 to 2038, since a lookup-only gate would pass today.

@Xuanwo Xuanwo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to land, @andygrove! Thank you for carrying this!

@viirya viirya left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @andygrove. The GapInfo implementation checks out: reading a gap time with the later offset lands before the transition, so following(..).next() is the one that opened the gap. I also confirmed the allowlist isn't masking engine differences today: every listed zone differs in UTC offsets, and none differs only in local-time or gap results.

Nit: the lockfile still bumps opendal's jiff 0.2 (0.2.35 → 0.2.41, dropping defmt and others). Now that arrow-array is on 1.0, that's unrelated and could be reverted.

Comment thread arrow-array/src/timezone.rs Outdated
.into_iter()
.all(|s| agree(variant, jiff, &at(s)));
}
if !same {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allowlisted zones skip the local-time and GapInfo checks entirely, and they include the trickiest cases: Brazil's midnight changes, Havana's midnight folds, and Dublin's negative DST. Would allowing differences per (zone, year range) be worth the upkeep? Fine as a follow-up.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. dc062fd does this without a list to maintain. The test now finds the years in which a zone's UTC offsets differ between the two releases, and skips only those years and the years either side. Every other year must also agree on local times and GapInfo. So Brazil is skipped only around 1965 and 1966, Havana around 2026 and 2027, and Dublin around 1925. All 49 listed zones pass. As a check, I swapped the fold order for America/Sao_Paulo only. The old test still passed, and the new one fails at 1932-03-31 23:59:59.

@alamb alamb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a quick skim and t looks pretty good. There are still some overly specific comments I think we should trim, but otherwise looks like a step in the right direction to me

Comment thread .github/workflows/arrow.yml Outdated
cargo test -p arrow-array --all-features
# Disable feature `force_validate`
cargo test -p arrow-array --features=ffi
# `--all-features` resolves named timezones with jiff, so test chrono-tz on its own

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think the detail about named timezones is too specif here and below -- the point is to test with the jiff feature (which over time will have more than just named timezones)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in a137948. The steps are now named "with jiff", and the two comments only say that jiff takes precedence over chrono-tz, which is why chrono-tz gets its own test and clippy runs.

Comment thread arrow-array/src/lib.rs Outdated
pub mod temporal_conversions;
pub mod timezone;
// `jiff` takes precedence over `chrono-tz` when both are enabled, leaving chrono-tz compiled but
// unreferenced. Keep `-D unused_crate_dependencies` satisfied for `--all-features` builds.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the purpose of saying " Keep -D unused_crate_dependencies satisfied for --all-features builds." here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was needed originally to fix a clippy error, but is no longer needed (apparently because we now use cargo-shear, but I didn't confirm)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed now

Comment thread arrow-array/src/timezone.rs Outdated
}

#[test]
fn test_tzdb_version() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this test could probably be dropped -- as the API is just a pass through

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dropped

Comment thread arrow/README.md Outdated
- `prettyprint` - support for formatting record batches as textual columns
implementations of some [compute](https://github.com/apache/arrow-rs/tree/main/arrow/src/compute/kernels)
- `chrono-tz` - support of parsing timezone using [chrono-tz](https://docs.rs/chrono-tz/0.6.0/chrono_tz/)
- `jiff` - support of parsing timezone using [jiff](https://docs.rs/jiff/latest/jiff/), which keeps applying a zone's daylight saving rules past the last precomputed transition. Takes precedence over `chrono-tz`, so enabling it for any crate in a build applies to the whole build

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again I think here the jiff feature flag is going to apply to much more than timezone parsing, so continually referencing timezones is a bit of tech debt that we will have to clean up

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reworded it, but still kept a reference to timezones since that is all that is currently handled.

The `jiff` feature is expected to cover more than named timezones as
arrow moves to jiff, so the CI step names, the README and the feature
comments describe the feature rather than its current effect. The
`timezone` module docs keep the timezone details.

Remove `use chrono_tz as _`, which kept the
`-D unused_crate_dependencies` clippy checks passing. apache#11476 replaced
those checks with cargo-shear, which passes without it. Drop the
`tzdb_version` test, since the function only passes the release through.
opendal's jiff 0.2 stays at 0.2.35, as on main. The lockfile now only
adds the jiff 1.0 packages that arrow-array uses.
Zones in the allowlist skipped the local-time and GapInfo comparison
entirely, and they include Brazil's midnight transitions, Havana's
midnight folds and Dublin's negative DST. Skip only the years in which
the two releases give different UTC offsets, and the years either side,
so that these zones are compared outside the few years their data
changed. No list of years needs maintaining.
@andygrove

Copy link
Copy Markdown
Member Author

Thanks @alamb and @viirya.

  • a137948 addresses @alamb's review. Besides the inline points, it shortens the longest remaining comments and the DataType::Timestamp docs.
  • 516469d reverts the unrelated jiff 0.2 bump in Cargo.lock that @viirya noticed. opendal stays on jiff 0.2.35, and the lockfile only adds the jiff 1.0 packages that arrow-array uses.
  • dc062fd runs the local-time and GapInfo comparison for the zones in the allowlist too, except around the years their data changed.

@mbutrovich mbutrovich left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @andygrove. Swapping only the engine behind Tz makes this easy for downstream projects to try, and the comparison with chrono-tz gives good coverage up to 2099.

Comment on lines +418 to +420
/// chrono-tz keeps its last offset after 2099, while jiff keeps applying daylight saving
#[test]
fn test_dst_applies_after_2099() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test checks offsets at noon on January 1 and July 1, and the comparison with chrono-tz stops at 2099. So nothing checks gaps, folds, or GapInfo after 2099, which is where this feature's results are new. That's also the path a per-zone transition table from Phase 2 on #9183 would replace, so a test here would guard that change too. Could you add something like this?

/// After 2099 only jiff applies daylight saving, so the comparison with chrono-tz
/// cannot check gaps and folds there
#[test]
fn test_gaps_and_folds_after_2099() {
    let tz: Tz = "America/Los_Angeles".parse().unwrap();
    let pacific_standard = FixedOffset::west_opt(8 * 60 * 60).unwrap();
    let pacific_daylight = FixedOffset::west_opt(7 * 60 * 60).unwrap();
    let at = |y, m, d, h, min| {
        NaiveDate::from_ymd_opt(y, m, d)
            .unwrap()
            .and_hms_opt(h, min, 0)
            .unwrap()
    };
    // The second Sunday in March and the first Sunday in November of each year
    for (year, spring, fall) in [(2100, 14, 7), (2300, 11, 4), (9998, 8, 1)] {
        let skipped = at(year, 3, spring, 2, 30);
        assert!(matches!(
            tz.offset_from_local_datetime(&skipped),
            LocalResult::None
        ));
        let gap = GapInfo::new(&skipped, &tz).unwrap();
        let (begin, begin_offset) = gap.begin.unwrap();
        assert_eq!(begin, at(year, 3, spring, 2, 0));
        assert_eq!(begin_offset.fix(), pacific_standard);
        let end = gap.end.unwrap();
        assert_eq!(end.naive_local(), at(year, 3, spring, 3, 0));
        assert_eq!(end.offset().fix(), pacific_daylight);

        match tz.offset_from_local_datetime(&at(year, 11, fall, 1, 30)) {
            LocalResult::Ambiguous(first, second) => {
                assert_eq!(first.fix(), pacific_daylight);
                assert_eq!(second.fix(), pacific_standard);
            }
            other => panic!("expected an ambiguous offset in {year}, got {other:?}"),
        }
    }
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in 1041671, with your dates. I reworded the doc comment to say that chrono-tz has no transitions after 2099. "Only jiff applies daylight saving" isn't quite true, since chrono-tz keeps Australia/Sydney on daylight time all year from 2100. As a check, chrono-tz gives a single PST offset at each gap and fold time in the test, so every assertion covers behaviour that is new with jiff.

The comparison with chrono-tz stops at 2099, because chrono-tz has no
later transitions, and the existing post-2099 test only reads offsets
at noon in January and July. Check a spring gap, its GapInfo, and a
fall fold in America/Los_Angeles in 2100, 2300 and 9998, where jiff's
results are new.

@mbutrovich mbutrovich left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @andygrove!

@andygrove
andygrove added this pull request to the merge queue Nov 20, 2026
@andygrove
andygrove removed this pull request from the merge queue due to a manual request Nov 20, 2026
@andygrove

Copy link
Copy Markdown
Member Author

I think this is good to go @alamb although I now remember that this repo has different rules than DataFusion about when PRs can be merged, so will leave it to you to make the call.

@alamb

alamb commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

I think it looks fine to me -- I think it might be good if @Jefffrey gave it a brief look as well before we merged, but I don't think we have any firm policy in place that requires that

Comment thread arrow/README.md Outdated
- `prettyprint` - support for formatting record batches as textual columns
implementations of some [compute](https://github.com/apache/arrow-rs/tree/main/arrow/src/compute/kernels)
- `chrono-tz` - support of parsing timezone using [chrono-tz](https://docs.rs/chrono-tz/0.6.0/chrono_tz/)
- `jiff` - use [jiff](https://docs.rs/jiff/latest/jiff/) for date and time support. It currently covers named timezones, and takes precedence over `chrono-tz`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we have a note here (and elsewhere where the jiff feature is) that its experimental, given its part of a staged migration? or is this change on its own sound enough that we dont need to call it experimental?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, makes sense to call it experimental for now.

Made these changes:

  • arrow/README.md: the jiff entry now starts with "⚠️ Experimental" and says what it covers and how it behaves may change, even between minor releases. This is the same wording as the parquet experimental
    features.
  • arrow-array/Cargo.toml: the comment on the jiff feature now says the same.
  • arrow-array/src/timezone.rs: the module docs now say the feature is experimental because it is a step in moving arrow-rs from chrono to jiff.

@andygrove
andygrove requested a review from Jefffrey November 24, 2026 15:59
@andygrove
andygrove added this pull request to the merge queue Nov 25, 2026
@andygrove

Copy link
Copy Markdown
Member Author

Thanks everyone. Enabled auto merge.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate arrow-array arrow-cast arrow-core Core crates related to representing arrow data arrow-kernels Crates that transform arrow data (e.g. compute, cast) arrow-schema development-process Internal changes; PRs with this label are excluded from changelog enhancement New feature/addition

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants