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

LakeShen commented on CALCITE-5994:
-----------------------------------

This PR is Ready, the PR link is : 
[https://github.com/apache/calcite/pull/3418] 

if others have time, please help me to review it, thank you very much:)

> When a sort's input max row cnt is 1,remove the redundant sort
> --------------------------------------------------------------
>
>                 Key: CALCITE-5994
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5994
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>            Reporter: LakeShen
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.36.0
>
>
> When a Sort's input source max row cnt is 1,then we could remove the 
> redundant Sort,the Sort could be a sorted semantic Sort(offset and fetch is 
> null).
> For example,the sql:
> {code:java}
> select * from (select * from tableA limit 1)  order by c ;
> {code}
> because the `(select * from tableA limit 1) ` max row cnt is 1, then we could 
> remove order by c
> {code:java}
> select * from tableA limit 1;
> {code}
> The sql:
> {code:java}
> select max(totalprice) from orders order by 1 {code}
> could converted to:
> {code:java}
> select max(totalprice) from orders{code}
> Above logic are same as Presto/Trino's 
> [RemoveRedundantSort|https://github.com/prestodb/presto/blob/c21fc28846252cd910d90f046514bf586d7bb5c6/presto-main/src/main/java/com/facebook/presto/sql/planner/iterative/rule/RemoveRedundantSort.java#L27]
>  rule:
>  



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

Reply via email to