questdb / questdb/questdb

syntax error when DISTINCT SELECT contains both star and explicit column list

Open
#6,521 1 comment 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.