← Back to Pull requests

fix: use historic zone offset for extreme-year string-to-timestamp casts #7255

Open
unknown opened this pull request with 233 lines diff across 2 files
View on GitHub
unknown unknown commented on Oct 27, 2026 15:21 UTC
Author

Which issue does this PR close?

Closes #7210.

Rationale for this change

For years outside chrono's NaiveDate range, the native string-to-timestamp path looked up the session timezone offset at 1970-01-01. That returns the zone's standard offset (for example -08:00 for America/Los_Angeles) instead of the local-mean-time offset Spark's ZoneRules use for dates before 1883. Casting -290308-12-21 19:59:05.224192 in an America/Los_Angeles session was therefore 422 seconds off from Spark (-9223372008054775808 vs -9223372008476775808).

1800-06-01 in 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_offset in native/spark-expr/src/conversion_funcs/string.rs:

  • America/Los_Angeles session cast of -290308-12-21 19:59:05.224192 matches Spark's LMT micros.

  • 1800-06-01 00:00:00 in the same zone stays pinned to the known Spark value.

  • UTC and +02:00 stay exact at the i64 microsecond 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, and cargo fmt pass.

    This PR was prepared with AI assistance and reviewed and tested by the author.

    Diff: 233 lines (+174 / -59) across 2 files Reviewer: sunchao Review duration: 6908m
    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
    0.37
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 37.1% (MEDIUM) · Higher = larger blast radius
    37.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.8% · Safe to merge
    19.8%