Skip to content

Commit d7d42bd

Browse files
committed
fix(query): correct datetime ranges and timezone transitions (#20416)
Replace Jiff-backed SQL datetime projections and arithmetic with Chrono and chrono-tz while keeping session time zones as `chrono_tz::Tz`. Use a per-day timezone lookup cache for common projections and one resolver for local-time folds and gaps. Fall back to chrono-tz outside the cached years, preserve the source side of a fold when possible, and support the full Date, Timestamp, and TIMESTAMP_TZ range, including local year 10000 after applying a positive offset. Correct interval arithmetic across timezone transitions: calendar months and days preserve wall-clock semantics, elapsed microseconds remain timeline arithmetic, and fixed-offset TIMESTAMP_TZ values remain DST-free. Make DATE +/- INTERVAL return TIMESTAMP while retaining the existing SQL clamp behavior. Reject explicit-offset and formatted parser results outside the SQL TIMESTAMP domain, including Unix-second values beyond year 9999. Update parsing, formatting, COPY, Variant, and task-history consumers, and consolidate timezone and interval regressions in table-driven SQLLogicTests. Release benchmarks process 100,000 rows and compare this change with upstream/main on the same machine using clean builds, CPU pinning, warmups, and alternating paired runs. Median results are: - convert_timezone: 9.598 ms -> 6.659 ms (-30.5%) - timestamp_extract_components: 12.900 ms -> 9.133 ms (-29.2%) - timestamp_add_months: 14.720 ms -> 14.150 ms (-3.7%) - date_add_days: 67.16 us -> 67.16 us (no change) - string_parse_standard_to_date: 36.625 ms -> 14.245 ms (-61.2%) - string_parse_to_date: 26.290 ms -> 12.250 ms (-53.2%) - string_parse_to_timestamptz: 12.580 ms -> 3.126 ms (-75.2%)
1 parent 92d1a6e commit d7d42bd

76 files changed

Lines changed: 3628 additions & 3610 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 47 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ bytes = "1.5.0"
231231
bytesize = "2"
232232
cbordata = { version = "0.6.0" }
233233
cfg-if = "1.0.0"
234-
chrono = { version = "0.4.40", features = ["serde"] }
235-
chrono-tz = { version = "0.8", features = ["serde"] }
234+
chrono = { version = "0.4.45", features = ["serde"] }
235+
chrono-tz = { version = "0.10.4", features = ["serde"] }
236236
cidr = { version = "0.3.1" }
237237
clap = { version = "4.4.2", features = ["derive"] }
238238
codeq = { version = "0.5.2" }

src/common/column/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ arrow-buffer = { workspace = true }
2525
arrow-data = { workspace = true }
2626
arrow-schema = { workspace = true }
2727
bytemuck = { workspace = true }
28+
chrono = { workspace = true }
2829
either = { workspace = true }
2930
ethnum = { workspace = true }
3031
foreign_vec = { workspace = true }
3132
hex = { workspace = true }
32-
jiff = { workspace = true }
3333
log = { workspace = true }
3434
match-template = { workspace = true }
3535
num-traits = { workspace = true }

0 commit comments

Comments
 (0)