Custom ordering with GROUP BY ALL
- Dominant language
- C++
- Stars
- 41.2k
- Forks
- 3.8k
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 491
Description
### What happens?
Attempt to reorder results of a GROUP BY ALL aggregation using a derived field such as `LOWER(name)` does not work.
### To Reproduce
```sql
CREATE TABLE df AS SELECT 'aBcaBc' AS name, x FROM range(0, 6) r(x);
SELECT name, SUM(x) FROM df GROUP BY ALL ORDER BY name;
SELECT name, SUM(x) FROM df GROUP BY name ORDER BY LOWER(name);
SELECT name, SUM(x) FROM df GROUP BY name ORDER BY CASE WHEN name ='B' THEN 1 ELSE 0 END;
SELECT name, SUM(x) FROM df GROUP BY ALL ORDER BY LOWER(name);
```
```console
Binder Error:
column "name" must appear in the GROUP BY clause or must be part of an aggregate function.
GROUP BY ALL will only group entries in the SELECT list. Add it to the SELECT list or GROUP BY this entry explicitly.
```
### OS:
any
### DuckDB Version:
1.4.0
### DuckDB Client:
python
### Hardware:
_No response_
### Full Name:
Alex Kislukhin
### Affiliation:
self
### What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.
I have tested with a stable release
### Did you include all relevant data sets for reproducing the issue?
No - Other reason (please specify in the issue body)
### Did you include all code required to reproduce the issue?
- [x] Yes, I have
### Did you include all relevant configuration (e.g., CPU architecture, Python version, Linux distribution) to reproduce the issue?
- [x] Yes, I have
Contributor guide
Research direction
No source files, tests, or entry points are named. Start by running the supplied SQL reproduction against DuckDB 1.4.0 and a current build, then locate the binder error for GROUP BY ALL and compare it with the working GROUP BY name cases. Done means derived ORDER BY expressions work with GROUP BY ALL without the reported binder 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
- 35/100