apache / apache/druid

Cryptic error coming from Druid SQL in semi-join condition

Open
#8,246 4 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.16.0-snapshot

### Description

The query

```sql
SELECT
"segment_id", "datasource", "start", "end"
FROM sys.segments
WHERE
"start" IN (
SELECT "start"
FROM sys.segments
WHERE "datasource" = 'wikiticker'
GROUP BY 1
LIMIT 5
)
AND "datasource" = 'wikiticker'
ORDER BY "start" DESC
LIMIT 100
```

Produces this cryptic error:

`Unknown exception / Got a sink null to which there is no match source type! / java.lang.IllegalStateException`

But strangely removing the `datasource` filter clause in the outer SQL makes it all work:

![image](https://user-images.githubusercontent.com/177816/62517102-775fd200-b7db-11e9-9904-6a0e0ec868da.png)

As it stands right now this is a release blocker for 0.16.0 as this type of query is generated by a feature added to the web console. To unblock we could do one of:

1. Fix this issue
2. Remove/hide the 'group by interval' feature in the segments view
3. Change how that view fetches data (make it make two calls)

2 or 3 are very simple to do but wanted to get some discussion going on weather we should do 1.

Contributor guide

Open the contributing guide

Research direction

Reproduce the reported query against Druid 0.16.0-snapshot, comparing the version with and without the outer datasource filter. Trace the semi-join path that produces the “sink null” IllegalStateException; done means the query no longer returns the cryptic error, or the segments-view workaround is clearly selected and verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, sql
Domain
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.