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

AggregateMergeRule should merge SUM0 into COUNT even if GROUP BY is empty

    XMLWordPrintableJSON

Details

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

    Description

      AggregateMergeRule should merge SUM0 into COUNT even if GROUP BY is empty.

      Basically, the comment inĀ AggregateMergeRule,

      Should not merge if top agg with empty group keys and the lower agg function is COUNT, because in case of empty input for lower agg, the result is empty, if we merge them, we end up with 1 result with 0, which is wrong.

      does not apply if the top aggregate is a SUM0, I believe. Without a fix for this, there's this one case where this rule falls down and isn't able to merge something that just got rolled up: otherwise it's a pretty nice invariant that if one of our standard rollup rules for aggregates (say, in MaterializedViewRule) just split the aggregate, this rule should be able to merge it back.

      Attachments

        Issue Links

          Activity

            People

              julianhyde Julian Hyde
              swtalbot Steven Talbot
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: