Skip to content

timestamp_ntz_to_timestamp panics on ambiguous or non-existent local times (DST transitions) #3864

@matthewalex4

Description

@matthewalex4

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:00 in Europe/London — this time never occurs as clocks skip from 01:00 → 02:00, so LocalResult::None is returned and from_local_datetime(...).unwrap() panics.
  • Ambiguous (fall back): e.g. 2024-10-27 01:30:00 in Europe/London — this time occurs twice as clocks repeat 01:00 → 02:00, so LocalResult::Ambiguous is returned and from_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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriority:criticalData corruption, silent wrong results, security issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions