syntax error when DISTINCT SELECT contains both star and explicit column list
Open
Nobody has claimed this yet.
Bug
Friction
- Dominant language
- Java
- Stars
- 17.3k
- Forks
- 1.7k
- Avg merge
- 5d 10h
- Merged PRs (30d)
- 28
Description
To reproduce
This works on the demo:
select symbol from core_price where timestamp in '2025-12-08T10';
This also works:
select distinct symbol from core_price where timestamp in '2025-12-08T10';
This works too:
select distinct * from core_price where timestamp in '2025-12-08T10';
This works as well (one of the symbol columns gets a sythetic suffix)
select symbol, * from core_price where timestamp in '2025-12-08T10';
but this does not work:
select distinct symbol, * from core_price where timestamp in '2025-12-08T10';
The query errors out with Duplicate column [name=symbol]
As a QuestDB user, I consider this to be a surprising inconsistency.
QuestDB version:
9.2.2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reported SQL in a local QuestDB instance, then trace the SQL parser and projection handling for DISTINCT queries that combine an explicit column with *. Add a regression test for the exact query and verify that it no longer raises Duplicate column while the other listed queries continue to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100