You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "alamb (via GitHub)" <gi...@apache.org> on 2023/02/15 20:55:53 UTC

[GitHub] [arrow-datafusion] alamb opened a new issue, #5293: Error with query that has DISTINCT with ORDER BY and aliased select list

alamb opened a new issue, #5293:
URL: https://github.com/apache/arrow-datafusion/issues/5293

   **Describe the bug**
   https://github.com/apache/arrow-datafusion/pull/5132 introduced a regression regarding ordering by alias columns that were also marked as DISTINCT
   
   **To Reproduce**
   ```sql
   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
   
   ```sql
   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. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb closed issue #5293: Error with query that has DISTINCT with ORDER BY and aliased select list

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb closed issue #5293: Error with query that has DISTINCT with ORDER BY and aliased select list
URL: https://github.com/apache/arrow-datafusion/issues/5293


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org