questdb
questdb copied to clipboard
Wrong results on DISTINCT on subqueries
Describe the bug
I am getting wrong query results on subqueries using DISTINCT
To reproduce
Consider the following query
SELECT DISTINCT TICKER FROM TABLEA
UNION
SELECT DISTINCT TICKER FROM TABLEB
UNION
SELECT DISTINCT TICKER FROM TABLEC
Results may be
tickerA1, TickerA2, TickerB1, TickerB2, TickerC1, TickerC2
However, consider the following:
SELECT DISTINCT TICKER FROM
(
SELECT DISTINCT TICKER FROM TABLEA
UNION
SELECT DISTINCT TICKER FROM TABLEB
UNION
SELECT DISTINCT TICKER FROM TABLEC
)
Results are
Results may be
tickerA1, TickerA2
Expected Behavior
In this case, the tickers across tables A,B,C are all unique. So I expect the same result for both queries. In case there were duplicates, I would expect the query results to be the unique list of tickers across all 3 tables.
Environment
- **QuestDB version**: 6.3.1
- **OS**:Windows server
- **Browser**: n/a
Additional context
No response
Hi @TheTanc could you double check whether this is fixed by #2123 in 6.4.1? Thanks!
@pswu11 I tested the given queries and the issue seems to be fixed, probably by the mentioned PR.
Thanks a lot @Belair34 for confirming!