jeffreyssmith2nd opened a new issue, #11653: URL: https://github.com/apache/datafusion/issues/11653
### Is your feature request related to a problem or challenge? Currently, comparing two times with different timezones gives an error (see reproducer below). The [error](https://github.com/apache/datafusion/blob/b685e2d4f1f245dd1dbe468b32b115ae99316689/datafusion/expr/src/type_coercion/binary.rs#L81) occurs when attempting type coercion on the two inputs to the less greater than comparison. You can see the reproducer below, this feels like a natural query that someone may want to execute (they want the data back in UTC, but know the time based on their local timezone for filtering). ### Describe the solution you'd like According to the [arrow documentation](https://github.com/apache/arrow-rs/blob/fa2fbfdc8bcd043966cbfb1ddda55a7e76e8082c/arrow-schema/src/datatype.rs#L139), all timestamps with timezones are stored relative to UTC epoch, with the timezone used to offset. In theory this should allow us to compare two times from different timezones. The question becomes what type should the comparison return? Always the type on the left, the right, UTC if exists, something else? In this specific example, we know that UTC would be an appropriate Signature type based on the rest of the SELECT statement, maybe there is enough information (or enough can be provided) to make that determination during planning. ### Describe alternatives you've considered _No response_ ### Additional context #### Simple Reproducer ``` copy ( values (arrow_cast('2024-07-25', 'Timestamp(Nanosecond, Some("UTC"))')), (arrow_cast('2024-07-24', 'Timestamp(Nanosecond, Some("UTC"))')) ) to 'example.parquet'; ``` ``` select column1 from 'example.parquet' where column1 > '2020-06-01T00:00:00' at time zone 'America/New_York'; ``` Provides the error: ``` Error during planning: Cannot infer common argument type for comparison operation Timestamp(Nanosecond, Some("UTC")) > Timestamp(Nanosecond, Some("America/New_York")) ``` -- 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]
