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

Add a rule to merge a Project onto an Aggregate

    XMLWordPrintableJSON

    Details

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

      Description

      Add a rule to merge a Project onto an Aggregate. In practice, it means that aggregate functions that are not used in the Project are removed from the Aggregate.

      For example,

      SELECT deptno, sum_sal
      FROM (
        SELECT deptno, job, SUM(sal) AS sum_sal, MIN(ename) AS min_ename
        FROM emp
        GROUP BY deptno, job)
      

      becomes

      SELECT deptno, sum_sal
      FROM (
        SELECT deptno, job, SUM(sal) AS sum_sal
        FROM emp
        GROUP BY deptno, job)
      

      Note that min_ename is removed from the Aggregate (because it is not used by the Project). job is not used, but it remains because it is a GROUP BY key.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                julianhyde Julian Hyde
                Reporter:
                julianhyde Julian Hyde
              • Votes:
                0 Vote for this issue
                Watchers:
                3 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 - 40m
                  40m