Repository navigation
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
It looks from_unixtime supports only -8334601211038 <= sec <= 8210266876799
To Reproduce
$datafusion-cli
DataFusion CLI v48.0.0
> select from_unixtime(8210266876799, 'America/New_York');
+--------------------------------------------------------------+
| from_unixtime(Int64(8210266876799),Utf8("America/New_York")) |
+--------------------------------------------------------------+
| +262142-12-31T18:59:59-05:00 |
+--------------------------------------------------------------+
1 row(s) fetched.
Elapsed 0.039 seconds.
> select from_unixtime(8210266876799 + 1, 'America/New_York');
+----------------------------------------------------------------------------------------------------------------+
| from_unixtime(Int64(8210266876799) + Int64(1),Utf8("America/New_York")) |
+----------------------------------------------------------------------------------------------------------------+
| ERROR: Cast error: Failed to convert 8210266876800 to datetime for Timestamp(Second, Some("America/New_York")) |
+----------------------------------------------------------------------------------------------------------------+
1 row(s) fetched.
Elapsed 0.006 seconds.
> select from_unixtime(-8334601211038, 'America/New_York');
+---------------------------------------------------------------+
| from_unixtime(Int64(-8334601211038),Utf8("America/New_York")) |
+---------------------------------------------------------------+
| -262143-01-01T00:00:00-04:56 |
+---------------------------------------------------------------+
1 row(s) fetched.
Elapsed 0.001 seconds.
> select from_unixtime(-8334601211038 -1, 'America/New_York');
thread 'main' panicked at ...
Local time out of range for `NaiveDateTime`
Expected behavior
We should be able to convert all Int64 values
Additional context
Spark can convert those large numbers
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Activity
comphead commentedon Jun 27, 2025
it is prob because of https://docs.rs/chrono/latest/chrono/naive/struct.NaiveDateTime.html#panics
Omega359 commentedon Jul 1, 2025
DF delegates to arrow for this which uses Chrono. https://docs.rs/chrono/latest/src/chrono/naive/date/mod.rs.html#1431 Switching to a different library such as jiff will likely not resolve the issue (https://docs.rs/jiff/latest/src/jiff/civil/datetime.rs.html)
fix: reject `from_unixtime` values whose local date and time is out o…
fix: `from_unixtime` should respect `datafusion.execution.time_zone` (a…