apache / apache/druid

Bug in SQL grouping shortcut

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

Description

Seen in Druid 24.0 and Druid 25.0

With `kttm_simple` loaded from the `Demo 1` demo query observe this behavior:

```
SELECT
count(*),
(case
when TIME_PARSE("timestamp", NULL, 'Asia/Kolkata')

Something is not right here. My understanding is that `GROUP BY 2` is just a shortcut.

Originally reported here: https://apachedruidworkspace.slack.com/archives/C0303FDCZEZ/p1672226327432399

Contributor guide

Open the contributing guide

Research direction

Start with the Demo 1 query using the kttm_simple datasource and compare GROUP BY 2 with the expanded CASE expression shown in the report. Trace the SQL planning or validation path that handles ordinal grouping, then add a regression test demonstrating that both forms behave equivalently; done means the ordinal form runs without the grouping error.

Written by the indexing model from the issue text.

Assessment

Tech stack
sql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.