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

Prune Project's input if project has no InputRef and the input has 1 row

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.35.0
    • core

    Description

      Prune Project's input if project has no RexInputRef and the input has 1 row. The idea is to improve SQL

      select 1 from emps group by ()
      

      In this case, we can safely prune the Aggregate. To be more specifically, I'm proposing to match a Project -> Aggregate, and the Project has not field reference from the Aggregate, and the Aggregate's grouping list is empty (which means it will produce 1 row exactly), in this case, we can optimize it to Project -> Values(1) to eliminate the Aggregate.

      This idea is brought up in the discussion of CALCITE-5506

      We can add this improvement to ProjectAggregateMergeRule.

      Attachments

        Issue Links

          Activity

            People

              libenchao Benchao Li
              libenchao Benchao Li
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: