[ 
https://issues.apache.org/jira/browse/CALCITE-4040?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17127826#comment-17127826
 ] 

xzh_dz commented on CALCITE-4040:
---------------------------------

[~julianhyde] Thank you for your comments. This is a bug of materialized 
recognition. If there is no correct recognition in the process of materialized 
recognition, materialized recognition should return to the original relnode. 
When an SqlAggFunction does not support roll up, it will return null, which 
means that it cannot do secondary aggregation and the materialization 
recognition will fail, it should return original RelNode. Throwing an exception 
is not a correct way.

> An aggregate function that does not support roll up throws an exception when 
> it is rolled up
> --------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-4040
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4040
>             Project: Calcite
>          Issue Type: Wish
>            Reporter: xzh_dz
>            Priority: Major
>          Time Spent: 1h 10m
>  Remaining Estimate: 0h
>
> When i try to rollup some SqlAggFunctions in my project,I find something 
> wrong.
> A case can be reproduced as below:
> MaterializationTest:
> {code:java}
> @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);
>   }
> {code}
>  If sql is not materialized, it should not throw an exception.
> Exception:
> {code:java}
> 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)
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to