Fix timestamp literal handling in the multi-stage query engine #14502
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
java.util.Calendar
. However, the internal representation used by Calcite for timestamp types isorg.apache.calcite.util.TimestampString
(see here). External callers usually convert this toCalendar
orLong
(see here), but this doesn't always appear to be the case.Sarg
(search argument) - this issue was detected by a query with a filter predicate likeWHERE ts BETWEEN '2016-01-01 00:00:00' AND '2016-01-01 10:00:00'
where the class cast exceptionclass org.apache.calcite.util.TimestampString cannot be cast to class java.util.Calendar
was thrown when converting the bounds of a range here during conversion ofSEARCH
to anOR
of ranges. This wasn't a major issue until recently because search nodes were usually reduced before the final query plan was generated (which changed in Apply filter reduce expressions Calcite rule at the end to prevent literal-only filter pushdown to leaf stage #14448).Calendar
based cast logic toTimestampString
based cast logic is also incorrect and a query with a filter predicate likeWHERE ts >= CAST(1454284798000 AS TIMESTAMP)
will fail with a class cast exceptionclass java.util.GregorianCalendar cannot be cast to class org.apache.calcite.util.TimestampString
.