apache / apache/druid

Join queries with order by clause doesn't work

Open
#13,163 6 comments 0 reactions 0 assignees View on GitHub
Area - Querying Area - SQL
Dominant language
Java
Stars
14.1k
Forks
3.8k
Avg merge
2d 58m
Merged PRs (30d)
233

Description

Hi!
Join queries with order by clause doesn't work

### Affected Version

0.23.0, 0.24.0

### Description

Queries like (with join and order by clause):
```
SELECT "T1"."__time"
FROM "SomeTableA" AS "T1"
JOIN "SomeTableB" AS "T2"
ON "T1"."A" = "T2"."B"
ORDER BY "T1"."__time" ASC
```
Doesn't work at 0.23.0 and 0.24.0 versions of Druid (but works at 0.22.0).
"Doesn't work" means that query processing ends with exception on broker node:
```
Error: Unknown exception
Cannot convert query parts into an actual query
org.apache.druid.sql.calcite.rel.CannotBuildQueryException
```
More detailed log here:
[broker.log](https://github.com/apache/druid/files/9686541/broker.log)

Contributor guide

Open the contributing guide

Research direction

Reproduce the SQL query against Druid 0.23.0 or 0.24.0 and review the linked broker.log alongside CannotBuildQueryException. Trace the broker query-planning path that handles JOIN with ORDER BY; done means the example query executes successfully without the broker exception, while preserving the behavior reported for 0.22.0.

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
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.