gianm opened a new issue, #13400:
URL: https://github.com/apache/druid/issues/13400
Sometimes people omit the word `TIMESTAMP` before a time literal, which
makes it a `VARCHAR`.
With expressions like `__time >= '2001-03-01'`, the `VARCHAR` is implicitly
cast to `TIMESTAMP` by Calcite. It generates a RexNode like `>=($0,
CAST('2001-03-01'):TIMESTAMP(3) NOT NULL)`. Something similar happens for `<`
too. For some reason, this doesn't happen for `=`. Calcite generates a RexNode
like `=($0, '2001-03-01')`.
This causes errors in our SQL-to-native translation code, which assumes that
literals compared with `__time` are of `TIMESTAMP` type.
Here's a test query that fails if added to
`CalciteQueryTest#testCountStarWithTimeFilterUsingStringLiterals`:
```
SELECT COUNT(*) FROM druid.foo
WHERE __time >= '2000-01-01 00:00:00' AND __time < '2001-01-01T00:00:00'
OR __time >= '2001-02-01' AND __time < '2001-02-02'
OR __time BETWEEN '2001-03-01' AND '2001-03-02'
OR __time = '2001-04-01'
OR __time = '2001-05-01 00:00:00'
OR __time = '2001-06-01T00:00:00'
```
--
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]