[ https://issues.apache.org/jira/browse/CALCITE-5994?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
ASF GitHub Bot updated CALCITE-5994: ------------------------------------ Labels: pull-request-available (was: ) > 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 > > 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)