Unsatisfiable WHERE clause leads to exception instead of empty result
- Dominant language
- Java
- Stars
- 14.1k
- Forks
- 3.8k
- Avg merge
- 2d 58m
- Merged PRs (30d)
- 233
Description
### Affected Version
0.23.0
### Description
The following query
```sql
SELECT *
FROM "druid"."mydata"
WHERE false
ORDER BY "__time" DESC
```
leads to the following error:
`druid error: Unsupported operation (org.apache.druid.java.util.common.UOE): Time-ordering on scan queries is only supported for queries with segment specs of type MultipleSpecificSegmentSpec or SpecificSegmentSpec...a [MultipleIntervalSegmentSpec] was received instead.`
false can be an arbitrary unsatisfiable boolean expression. I came across it when trying to filter for a specific exact timestamp in Superset, which is translated into the unsatisfiable expression
```sql
WHERE MILLIS_TO_TIMESTAMP(recordTimeParsed) >= TIME_PARSE('2022-09-25T00:00:00')
AND MILLIS_TO_TIMESTAMP(recordTimeParsed) < TIME_PARSE('2022-09-25T00:00:00')
```
Since it seems to be valid vor any unsatisfiable WHERE clause, I'm omitting details about my specific dataset.
Contributor guide
Research direction
Reproduce the supplied SQL against Druid 0.23.0 and trace the query path for an unsatisfiable WHERE clause combined with ORDER BY __time. Done means the query returns an empty result instead of raising the reported time-ordering exception; the payload names no source file or test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, sql
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100