You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (Jira)" <ji...@apache.org> on 2020/10/19 17:38:00 UTC

[jira] [Commented] (CALCITE-4345) SUM CASE WHEN xxx THEN 1 without "ELSE" throws NPE in AggregateCaseToFilterRule

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

Julian Hyde commented on CALCITE-4345:
--------------------------------------

Please use 'noformat' rather than 'code' tag for stack traces, and preserve the original line breaks. Screen shots are not helpful because they cannot be searched.

> SUM CASE WHEN xxx THEN 1 without "ELSE" throws NPE in AggregateCaseToFilterRule
> -------------------------------------------------------------------------------
>
>                 Key: CALCITE-4345
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4345
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>            Reporter: Jiatao Tao
>            Assignee: Jiatao Tao
>            Priority: Major
>              Labels: pull-request-available
>         Attachments: image-2020-10-19-16-59-44-900.png
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Add a test in CsvTest:
>  
> {code:java}
> @Test void testSumCaseWhenWithoutElse() throws SQLException {
>   sql("model", "select sum( CASE WHEN empno=10 THEN 1 END ) from EMPS").ok();
> }
> {code}
> Will throw NPE
> {code:java}
>  Caused by: java.lang.RuntimeException: Error while applying rule AggregateCaseToFilterRule, args [rel#18:LogicalAggregate.NONE.[](input=RelSubset#17,group={},EXPR$0=SUM($0)), rel#16:LogicalProject.NONE.[](input=RelSubset#15,exprs=[CASE(=($0, 10), 1, null:INTEGER)])] Caused by: java.lang.RuntimeException: Error while applying rule AggregateCaseToFilterRule, args [rel#18:LogicalAggregate.NONE.[](input=RelSubset#17,group={},EXPR$0=SUM($0)), rel#16:LogicalProject.NONE.[](input=RelSubset#15,exprs=[CASE(=($0, 10), 1, null:INTEGER)])] at org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:257) at org.apache.calcite.plan.volcano.IterativeRuleDriver.drive(IterativeRuleDriver.java:58) at org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:511) at org.apache.calcite.tools.Programs.lambda$standard$3(Programs.java:271) at org.apache.calcite.tools.Programs$SequenceProgram.run(Programs.java:331) at org.apache.calcite.prepare.Prepare.optimize(Prepare.java:166) at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:299) at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:208) at org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:642) at org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:508) at org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:478) at org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(CalciteConnectionImpl.java:231) at org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:558) at org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:675) at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:156) ... 63 more Caused by: java.lang.NullPointerException at org.apache.calcite.rex.RexLiteral.intValue(RexLiteral.java:1152) at org.apache.calcite.rel.rules.AggregateCaseToFilterRule.transform(AggregateCaseToFilterRule.java:231) at org.apache.calcite.rel.rules.AggregateCaseToFilterRule.onMatch(AggregateCaseToFilterRule.java:115) at org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:230) ... 77 more
> {code}
>  
>  
>  



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