Skip to content

from_unixtime does not work for large values #16594

Description

@kazuyukitanimura

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions