-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Comparing a Timestamp
to a Date32
fails
#4644
Comments
@crepererum @waitingkuo I can take that as a next ticket related to timestamp issues |
thank you @comphead do you plan to do Timestamp without Timezone only or both Timestamp and TImestampTz? |
fyi this is straightforward willy=# select timestamp '2000-01-01T00:00:00.00000' = date '2000-01-01';
?column?
----------
t
(1 row) and there're more to consider for timestamptz (i'm in UTC+8) willy=# select timestamptz '2000-01-01T00:00:00.00000+00' = date '2000-01-01';
?column?
----------
f
(1 row) willy=# select timestamptz '1999-12-31T16:00:00.00000+00' = date '2000-01-01';
?column?
----------
t
(1 row) willy=# select timestamptz '2000-01-01T00:00:00.00000+08' = date '2000-01-01';
?column?
----------
t
(1 row) |
Simpler reproduce case
|
@waitingkuo those ts to date tests, did you run in datafusion cli?
I'm running it on master branch |
@comphead sorry i didn't mention it clearly. it's the behavior for postgresql |
I want to reopen this issue to discuss the implementation of the comparing between date and timestamp data type. cc @waitingkuo @alamb @crepererum I have comments about #4726 (comment)
|
This rule will not affect the comparison, we just need to support them in the
|
we need to try to make align with behavior of PG |
Do you have time to investigate the behavior for the comparison between timestamp with date? Do we need to consider the timezone for the comparison or not? @crepererum |
The arrow-rs kernel appears to support casting to/from timestamp without timezone (timezone is my reading of the code is that if the timestamp has a timezone the arrow kernel will fail (can not cast types) |
@alamb @liukun4515 thats right, we can cast from timestamp to date, as it timestamp is more accurate datatype |
I think we shouldn't cast timezones if both inputs have different timezones. If both have the same it's fine and if one has a timezone and the other one hasn't it's probably also fine (one is concrete and the other one is "don't care"). |
This is also good point to cast/compare timestamp and timestamptz |
I'm still debugging this. Looks like logical plan doesn't include an extra cast in |
Does you have test the comparison in the PG between timestamp with date? |
some investigation are here #4761 (comment) and #4761 (comment) |
This test works, it adds extra cast to Equal condition
But this still fails.
Debugging |
I found something weird. first logical plan failed silently on cast. second is arrow cast acts not consistently on the same inputs. so if I run through first test
but if I run second test
I'm looking what in arrow-rs can cause such non determined behaviuor Edit: looks like |
Waitin arrow-rs 32.0.0 to proceed |
Describe the bug
Comparing a
Timestamp
to aDate32
fails.To Reproduce
Add the following test to
timestamps.slt
:This fails w/:
Expected behavior
It works.
Additional context
Tested on 5c558e9 .
This is likely due to a like in
temporal_coercion
as well as this workaround:https://github.com/apache/arrow-datafusion/blob/5c558e9f6b3fe29ef0d5f78ec9465852d020d989/datafusion/optimizer/src/type_coercion.rs#L232-L239
Also see #3419.
The text was updated successfully, but these errors were encountered: