-
Notifications
You must be signed in to change notification settings - Fork 298
timestamp_ntz_to_timestamp panics on ambiguous or non-existent local times (DST transitions) #3864
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't workingpriority:criticalData corruption, silent wrong results, security issuesData corruption, silent wrong results, security issues
Description
Describe the bug
timestamp_ntz_to_timestamp panics when a local time is ambiguous or non-existent due to DST transitions:
- Non-existent (spring forward): e.g.
2024-03-31 01:30:00inEurope/London— this time never occurs as clocks skip from 01:00 → 02:00, soLocalResult::Noneis returned andfrom_local_datetime(...).unwrap()panics. - Ambiguous (fall back): e.g.
2024-10-27 01:30:00inEurope/London— this time occurs twice as clocks repeat 01:00 → 02:00, soLocalResult::Ambiguousis returned andfrom_local_datetime(...).unwrap()panics.
Both the TimestampMicrosecondType and TimestampMillisecondType branches are affected.
Steps to reproduce
// Non-existent time — spring forward
timestamp_ntz_to_timestamp(array_containing("2024-03-31 01:30:00"), "Europe/London", None); // panic!
// Ambiguous time — fall back
timestamp_ntz_to_timestamp(array_containing("2024-10-27 01:30:00"), "Europe/London", None); // panic!Expected behavior
The function should handle all LocalResult variants from from_local_datetime(...) without panicking. For ambiguous times, opt for the earlier option (consistent with e.g. Apache Spark). For a non-existent time, treat it like that time shifted an hour before.
Additional context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingpriority:criticalData corruption, silent wrong results, security issuesData corruption, silent wrong results, security issues