-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
#5132 introduced a regression regarding ordering by alias columns that were also marked as DISTINCT
To Reproduce
DataFusion CLI v18.0.0
❯ create or replace table t as select column1 as value, column2 as time from (select * from (values
(1, timestamp '2022-01-01 00:00:30'),
(2, timestamp '2022-01-01 01:00:10'),
(3, timestamp '2022-01-02 00:00:20')
) as sq) as sq
;
0 rows in set. Query took 0.007 seconds.
❯ SELECT DISTINCT time as "first_seen" FROM t ORDER BY time;
Plan("For SELECT DISTINCT, ORDER BY expressions time must appear in select list")Expected behavior
The query should succeed and produce the same answer as posgres
postgres=# postgres=# create table t as select column1 as value, column2 as time from (select * from (values
(1, timestamp '2022-01-01 00:00:30'),
(2, timestamp '2022-01-01 01:00:10'),
(3, timestamp '2022-01-02 00:00:20')
) as sq) as sq
;
SELECT 3
postgres=# SELECT DISTINCT time as "first_seen" FROM t ORDER BY time;
first_seen
---------------------
2022-01-01 00:00:30
2022-01-01 01:00:10
2022-01-02 00:00:20
(3 rows)Additional context
We found this internally in IOx.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working