You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Yu Xu (Jira)" <ji...@apache.org> on 2026/06/22 02:15:00 UTC

[jira] [Comment Edited] (CALCITE-5406) Support the SELECT DISTINCT ON statement for PostgreSQL dialect

    [ https://issues.apache.org/jira/browse/CALCITE-5406?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18090497#comment-18090497 ] 

Yu Xu edited comment on CALCITE-5406 at 6/22/26 2:14 AM:
---------------------------------------------------------

Fixed in [eaadc32|https://github.com/apache/calcite/commit/eaadc32db821186e4a887b804099c2dbdd96878d]

Thank you for reporting and suggestion [~julianhyde] [~asolimando]  [~duanzhengqiang] 

Thank you for the review [~mbudiu] [~jensen] cjj2010


was (Author: JIRAUSER307770):
Fixed in [eaadc32|https://github.com/apache/calcite/commit/eaadc32db821186e4a887b804099c2dbdd96878d]

Thank you for reporting and suggestion [~julianhyde]  [~duanzhengqiang] 

Thank you for the review [~mbudiu] [~jensen] cjj2010

> Support the SELECT DISTINCT ON statement for PostgreSQL dialect
> ---------------------------------------------------------------
>
>                 Key: CALCITE-5406
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5406
>             Project: Calcite
>          Issue Type: New Feature
>    Affects Versions: 1.32.0
>            Reporter: Zhengqiang Duan
>            Assignee: Yu Xu
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.43.0
>
>
> Hi, community, I am currently using Calcite to help ShardingSphere implement distributed database features. When we tested the SELECT DISTINCT ON statement in PostgreSQL(as shown in the following sql), we found that Calcite currently does not support the parsing and semantic processing of the SELECT DISTINCT ON statement. Considering that the SELECT DISTINCT ON statement in PostgreSQL is frequently used and valuable to users, we hope to support this new feature.
> {code:java}
> select distinct on (user_id) * from t_order order by user_id, order_id; {code}
> As suggested by [~asolimando]  and [~julianhyde] , first, we need to support SELECT DISTINCT ON statement parsing at PostgreSQL and lenient compliance level.
> Secondly, we need to investigate whether we need to rewrite in SqlToRelConverter or in planner rules? 
> I will investigate the solution to support this new feature and update it in jira later.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)