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

When matching materializations, match Project with child of Aggregate

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • None
    • 1.22.0
    • core

    Description

      In current code, SubstitutionVisitor & MaterializedViewSubstitutionVisitor fail to support below matching:

         query:   Project(projects: [$0, *(2, $1)])
                        Aggregate(groupSet: {0}, groupSets: [{0}], calls: [SUM($1)])
                           Scan(table: [hr, emps])</li>
         target:  Project(projects: [$0, *(2, $1), *(2, $2)])
                        Aggregate(groupSet: {0}, groupSets: [{0}], calls: [SUM($1), COUNT()])
                           Scan(table: [hr, emps])</li>
      

      And below test fails

      // MaterializationTest.java
        @Test public void testAggregate() {
          checkMaterialize(
            "select \"deptno\", count(1), 2 * sum(\"empid\") from "
              + "(select * from \"emps\" union all select * from \"emps\")"
              + "group by \"deptno\"",
            "select \"deptno\", 2 * sum(\"empid\") from "
              + "(select * from \"emps\" union all select * from \"emps\")"
              + "group by \"deptno\"");
        }
      

      The reason is that Project&Aggregate are not taken into consideration at the same time in current matching rules.
      It might make sense to create a rule of ProjectOnAggregateToProjectOnAggregateUnifyRule to handle such case.

      Attachments

        Issue Links

          Activity

            People

              jinxing6042@126.com Jin Xing
              jinxing6042@126.com Jin Xing
              Votes:
              0 Vote for this issue
              Watchers:
              2 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