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

Materialized View matching failed with NPE if aggregate function doesn't support roll up

    XMLWordPrintableJSON

Details

    • Wish
    • Status: Closed
    • Major
    • Resolution: Resolved
    • None
    • 1.24.0
    • None
    • None

    Description

      When i try to rollup some SqlAggFunctions in my project,I find something wrong.
      A case can be reproduced as below:
      MaterializationTest:

      @Test public void testSqlAggFunctionRollup() {
          checkNoMaterialize(
              "select \"empid\", stddev_pop(\"deptno\") from \"emps\" group by \"empid\", \"deptno\"",
              "select \"empid\", stddev_pop(\"deptno\") from \"emps\" group by \"empid\"",
              HR_FKUK_MODEL);
        }
      

      When an aggregate function does not support roll up, materialization recognition should fail and return the original relnode instead of throwing an exception.
      Exception:

      java.sql.SQLException: Error while executing SQL "explain plan for select "empid", stddev_pop("deptno") from "emps" group by "empid"": null
      
      	at org.apache.calcite.avatica.Helper.createException(Helper.java:56)
      	at org.apache.calcite.avatica.Helper.createException(Helper.java:41)
      	at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:163)
      	at org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:227)
      	at org.apache.calcite.test.CalciteAssert.assertQuery(CalciteAssert.java:528)
      Caused by: java.lang.NullPointerException
      	at java.util.Objects.requireNonNull(Objects.java:203)
      	at org.apache.calcite.rel.core.AggregateCall.<init>(AggregateCall.java:98)
      	at org.apache.calcite.rel.core.AggregateCall.create(AggregateCall.java:198)
      	at org.apache.calcite.plan.SubstitutionVisitor.unifyAggregates(SubstitutionVisitor.java:1854)
      	at org.apache.calcite.plan.SubstitutionVisitor$AggregateToAggregateUnifyRule.apply(SubstitutionVisitor.java:1545)
      	at org.apache.calcite.plan.SubstitutionVisitor.go(SubstitutionVisitor.java:544)
      	at org.apache.calcite.plan.SubstitutionVisitor.go(SubstitutionVisitor.java:478)
      
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            xzh_dz xzh_dz
            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 10m
                1h 10m