romanb opened a new issue, #19023:
URL: https://github.com/apache/datafusion/issues/19023

   ### Describe the bug
   
   Using the postgres dialect, the following query
   ```sql
   EXPLAIN SELECT (TIMESTAMP '2022-01-01T00:00:00')::timestamptz AS one, 
(TIMESTAMP '2022-01-01T01:00:00')::timestamptz AT TIME ZONE 'Europe/Berlin' AS 
two
   ```
   shows this logical plan
   ```
   Projection: TimestampNanosecond(1640995200000000000, None) AS one, 
TimestampNanosecond(1640995200000000000, Some("Europe/Berlin")) AS two   
EmptyRelation: rows=1
   ```
   I would (maybe naively) expect the cast to timestamptz to result in the 
default/session UTC time zone to be attached to the first expression (as 
happens in postgres). As a result, these two timestamp expressions are also not 
considered equal in `WHERE` query conditions using DataFusion. A workaround 
seems to be
   ```sql
   EXPLAIN SELECT (TIMESTAMP '2022-01-01T00:00:00')::timestamptz AT TIME ZONE 
'UTC' AS one, (TIMESTAMP '2022-01-01T01:00:00')::timestamptz AT TIME ZONE 
'Europe/Berlin' AS two
   ```
   which shows the logical plan
   ```
   Projection: TimestampNanosecond(1640995200000000000, Some("UTC")) AS one, 
TimestampNanosecond(1640995200000000000, Some("Europe/Berlin")) AS two   
EmptyRelation: rows=1
   ```
   and these two expressions are now also considered equal in `WHERE` clause 
query conditions.
   
   Maybe relates to https://github.com/apache/datafusion/issues/13212 and 
https://github.com/apache/datafusion/issues/12218.
   
   ### To Reproduce
   
   _No response_
   
   ### Expected behavior
   
   _No response_
   
   ### 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]

Reply via email to