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

Improve AggregateProjectPullUpConstantsRule to remove all constant keys

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.16.0
    • None
    • core

    Description

      Optimizer rule AggregateProjectPullUpConstantsRule removes constant keys from an Aggregate. However, this rules never removes the last column, because Aggregate([]) returns 1 row even if its input is empty. 

      An enhancement could be done to AggregateProjectPullUpConstantsRule so that it removes all constant keys:

      • Remove all constant keys from an Aggregate
      • (Only)When no key is left from previous step (Aggregate becomes Aggregate([])), add a filter to the Aggregate([]) so that it returns empty dataset if its input is empty. 

      E.g. 

      SELECT 'abc' FROM table_name GROUP BY ('abc')
      

      will be translated to:

      SELECT 'abc' FROM table_name GROUP BY () having count(*)>0
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              yingyu Yingyu Wang
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 10m
                  10m