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

Equivalent MutableAggregates with different row types fail with AssertionError

    XMLWordPrintableJSON

    Details

      Description

      Add test case in MaterializationTest:

      @Test public void testAggregateAlias() {
        checkMaterialize(
            "select count(*) as c from \"emps\" group by \"empid\"",
            "select count(*) + 1 as c from \"emps\" group by \"empid\"");
      }
      

       It fails due to different rowtype.

      java.lang.AssertionError
          at org.apache.calcite.plan.SubstitutionVisitor.go(SubstitutionVisitor.java:504)
          at org.apache.calcite.plan.SubstitutionVisitor.go(SubstitutionVisitor.java:465)
          at org.apache.calcite.plan.MaterializedViewSubstitutionVisitor.go(MaterializedViewSubstitutionVisitor.java:56)
          at org.apache.calcite.plan.RelOptMaterializations.substitute(RelOptMaterializations.java:200)
          at org.apache.calcite.plan.RelOptMaterializations.useMaterializedViews(RelOptMaterializations.java:72)
          at org.apache.calcite.plan.volcano.VolcanoPlanner.registerMaterializations(VolcanoPlanner.java:347)
      

      However, according to MutableAggregate's hashCode&equals implementation, this materialization can be reused, i.e., queryDescedant=targetDescendant.

      queryDescendant: RecordType(JavaType(int) empid, BIGINT $f1)
      =============================================================================
      Aggregate(groupSet: {0}, groupSets: [{0}], calls: [COUNT()])
        Project(projects: [$0])
          Scan(table: [hr, emps])
      
      targetDescendant: RecordType(JavaType(int) empid, BIGINT C)
      =============================================================================
      Aggregate(groupSet: {0}, groupSets: [{0}], calls: [COUNT()])
        Project(projects: [$0])
          Scan(table: [hr, emps])
      

      So, how can we align them?

       

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                danny0405 Danny Chen
                Reporter:
                donnyzone Feng Zhu
              • Votes:
                0 Vote for this issue
                Watchers:
                8 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 - 4h 40m
                  4h 40m