Commit d7d42bd
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
- src
- common
- column
- src/types
- io
- src
- cursor_ext
- tests/it/cursor_ext
- timezone
- src
- query
- expression
- src
- types
- utils
- test-support/src
- tests/it
- formats
- src
- field_decoder
- field_encoder
- output_format
- functions
- benches
- src
- aggregates
- scalars
- timestamp
- src
- tests/it/scalars
- testdata
- service
- src
- pipelines/processors/transforms
- sessions
- query_ctx
- table_functions/get_lineage
- task
- tests/it/servers/http
- settings
- src
- sql
- src/planner
- optimizer/ir/stats
- semantic/type_check
- storages
- common/stage
- src/read/columnar
- orc
- src
- processors
- parquet
- src/parquet_variant_table
- task_support
- src
- system_tables
- table_functions
- tests/sqllogictests/suites/query
- functions
- issues
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
231 | 231 | | |
232 | 232 | | |
233 | 233 | | |
234 | | - | |
235 | | - | |
| 234 | + | |
| 235 | + | |
236 | 236 | | |
237 | 237 | | |
238 | 238 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
32 | | - | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
0 commit comments