-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow comparison of Timestamps with different Timezones #11653
Comments
I suggest coercing both timestamps to UTC My rationale is that:
|
at least in SQL spec, the
can the comparison operator be a function that accepts timestamps in different zones? |
It could, but I think that would just postpone the conversation to execution (and it would likely be implemented the same, by calling the arrow |
take |
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 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, 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.
Alternatively, Signature::comparison could be updated to take separate types for the left and right hand sides.
Describe alternatives you've considered
No response
Additional context
Simple Reproducer
Provides the error:
The text was updated successfully, but these errors were encountered: