jeffreyssmith2nd opened a new issue, #12218:
URL: https://github.com/apache/datafusion/issues/12218
### Describe the bug
Using the `::timestamp` (or CAST()) function strips timezone information.
### To Reproduce
```
DataFusion CLI v40.0.0
> select arrow_typeof(now()) as tz;
+---------------------------------------+
| tz |
+---------------------------------------+
| Timestamp(Nanosecond, Some("+00:00")) |
+---------------------------------------+
> select arrow_typeof(now()::timestamp) as tz;
+-----------------------------+
| tz |
+-----------------------------+
| Timestamp(Nanosecond, None) |
+-----------------------------+
> select arrow_typeof((now() AT TIME ZONE 'America/Denver')::timestamp) as
tz;
+-----------------------------+
| tz |
+-----------------------------+
| Timestamp(Nanosecond, None) |
+-----------------------------+
```
Or as seen with actual values:
```
DataFusion CLI v40.0.0
> select now();
+-----------------------------+
| now() |
+-----------------------------+
| 2024-08-28T17:08:08.698528Z |
+-----------------------------+
> select (now() AT TIME ZONE 'America/Denver');
+----------------------------------+
| now() |
+----------------------------------+
| 2024-08-28T11:08:13.578025-06:00 |
+----------------------------------+
> select now()::timestamp;
+----------------------------+
| now() |
+----------------------------+
| 2024-08-28T17:08:17.228985 |
+----------------------------+
> select (now() AT TIME ZONE 'America/Denver')::timestamp;
+----------------------------+
| now() |
+----------------------------+
| 2024-08-28T17:08:20.042920 |
+----------------------------+
```
### Expected behavior
I would expect that using the `::timestamp` cast on a timestamp would not
impact its timezone. This is how Postgres behaves.
```
postgres@localhost:postgres> select now()::timestamp
+----------------------------+
| now |
|----------------------------|
| 2024-08-28 17:05:07.779323 |
+----------------------------+
postgres@localhost:postgres> select (now() at time zone
'America/Denver')::timestamp
+----------------------------+
| timezone |
|----------------------------|
| 2024-08-28 11:05:09.275359 |
+----------------------------+
```
### Additional context
_No response_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]