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

Remove Aggregate if grouping columns are unique and all functions are splittable

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.20.0
    • Component/s: None

      Description

      Remove Aggregate if grouping columns are unique and all functions are splittable. Currently AggregateRemoveRule is only applied if there are no aggregate functions. But we could optimize

      select deptno, count(name) from dept group by deptno

      to

      select deptno, 1 from dept

      because we know deptno is unique, name is not null, and a singleton count applied to a not null column evaluates to 1.

      See AggregateJoinTransposeRule; it already makes use of SqlSplittableAggFunction.

        Attachments

        1. node.png
          454 kB
          Haisheng Yuan

          Issue Links

            Activity

              People

              • Assignee:
                hyuan Haisheng Yuan
                Reporter:
                julianhyde Julian Hyde
              • Votes:
                0 Vote for this issue
                Watchers:
                4 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 - 1h 20m
                  1h 20m