Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-5994

Add optimization rule to remove Sort when its input's row number is less or equal to one

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.36.0
    • core

    Description

      When a Sort's input source max row numer 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:

      select * from (select * from tableA limit 1)  order by c ;
      

      because the `(select * from tableA limit 1) ` max row number is 1, then we could remove order by c

      select * from tableA limit 1;
      

      The sql:

      select max(totalprice) from orders order by 1 

      could converted to:

      select max(totalprice) from orders

      Above logic are same as Presto/Trino's RemoveRedundantSort rule:

       

      Attachments

        Issue Links

          Activity

            People

              shenlang LakeShen
              shenlang LakeShen
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: