apache / apache/druid

Unsatisfiable WHERE clause leads to exception instead of empty result

Open
#13,152 11 comments 0 reactions 0 assignees View on GitHub
Area - SQL Bug
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.