datafusion icon indicating copy to clipboard operation
datafusion copied to clipboard

Should `Cast(UTF-8 AS Timestamp)` apply local time zone?

Open waitingkuo opened this issue 3 years ago • 1 comments

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

dataufusion v10.0.0's applies local time zone (i'm in UTC+8)

❯ select cast('2000-01-01T00:00:00' as timestamp);
+------------------------------------------------------------------+
| CAST(Utf8("2000-01-01T00:00:00") AS Timestamp(Nanosecond, None)) |
+------------------------------------------------------------------+
| 1999-12-31 16:00:00                                              |
+------------------------------------------------------------------+
1 row in set. Query took 0.004 seconds.

while postgresql's is not

willy=# select cast('2000-01-01T00:00:00' as timestamp);
      timestamp      
---------------------
 2000-01-01 00:00:00
(1 row)

Describe the solution you'd like A clear and concise description of what you want to happen.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

waitingkuo avatar Aug 08 '22 16:08 waitingkuo

depends on apache/arrow-rs#1936

waitingkuo avatar Aug 09 '22 18:08 waitingkuo

I wonder if this item is now complete

alamb avatar Oct 19 '23 10:10 alamb

the original issue is fixed now

❯ select '2000-01-01T00:00:00'::timestamp;
+-----------------------------+
| Utf8("2000-01-01T00:00:00") |
+-----------------------------+
| 2000-01-01T00:00:00         |
+-----------------------------+
1 row in set. Query took 0.002 seconds

however it's not yet totally aligned with postgrseql datafusion

❯ select '2000-01-01T00:00:00+01:00'::timestamp;
+-----------------------------------+
| Utf8("2000-01-01T00:00:00+01:00") |
+-----------------------------------+
| 1999-12-31T23:00:00               |
+-----------------------------------+
1 row in set. Query took 0.002 seconds.

postgresql

willy=# select '2000-01-01T00:00:00+01:00'::timestamp;
      timestamp      
---------------------
 2000-01-01 00:00:00
(1 row)

Looks like Postgresql's behavior is to completely ignore the timezone part while casting string to timestamp

waitingkuo avatar Oct 19 '23 14:10 waitingkuo