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

Add rule to flatten two Aggregate operators into one

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.20.0
    • None

    Description

      If there is an Aggregate on top of an Aggregate, and the top aggregate's group key is a subset of the lower aggregate's group key, and the aggregates are expansions of rollups, then a rule would convert into a single aggregate.

      For example, SUM of SUM becomes SUM; SUM of COUNT becomes COUNT; MAX of MAX becomes MAX; MIN of MIN becomes MIN. AVG of AVG would not match, nor would COUNT of COUNT.

      The rule would convert

      Aggregate({x}, SUM(c1), MIN(c2), MAX(c3))
        Aggregate({x, y}, SUM(c1), MIN(c2), MAX(c3))
          R
      

      into

      Aggregate({x}, SUM(c1), MIN(c2), MAX(c3))
        R
      

      The rule would not work if there was anything between the two Aggregate operators.

      The implementation would use SqlSplittableAggFunction to deduce rollups, and in fact would be practically the converse of AggregateExchangeTransposeRule proposed in CALCITE-907.

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            julianhyde Julian Hyde
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

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

                Slack

                  Issue deployment