fix: use historic zone offset for extreme-year string-to-timestamp casts #7255
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.37) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 233 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.326
Real PR Conversation Timeline
1 comments
"Review active on #7255"
general
weight: 0.35
sunchao
Which issue does this PR close?
Closes #7210.
Rationale for this change
For years outside chrono's
NaiveDaterange, the native string-to-timestamp path looked up the session timezone offset at1970-01-01. That returns the zone's standard offset (for example-08:00forAmerica/Los_Angeles) instead of the local-mean-time offset Spark'sZoneRulesuse for dates before 1883. Casting-290308-12-21 19:59:05.224192in anAmerica/Los_Angelessession was therefore 422 seconds off from Spark (-9223372008054775808vs-9223372008476775808).1800-06-01in the same session already matched Spark, because that year is still inside chrono's range and chrono-tz applies LMT there. Only the extreme-year surrogate probe was wrong.What changes are included in this PR?
In
parse_timestamp_to_micros, the extreme-year branch now looks up the offset at the same civil time shifted toward the epoch by whole 400-year Gregorian cycles until the year fits in chrono's range. Leap days are preserved across the shift. Fixed offsets and UTC are unchanged. Far-future DST after chrono-tz's last transition (~2099) is unchanged and remains #6816.How are these changes tested?
New unit test
extreme_year_session_tz_uses_historic_offsetinnative/spark-expr/src/conversion_funcs/string.rs:America/Los_Angelessession cast of-290308-12-21 19:59:05.224192matches Spark's LMT micros.1800-06-01 00:00:00in the same zone stays pinned to the known Spark value.+02:00stay exact at thei64microsecond bounds.cargo test -p datafusion-comet-spark-expr extreme_year,cargo test -p datafusion-comet-spark-expr conversion_funcs::string::tests,cargo clippy -p datafusion-comet-spark-expr --all-targets -- -D warnings, andcargo fmtpass.This PR was prepared with AI assistance and reviewed and tested by the author.