You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "jingzhang (JIRA)" <ji...@apache.org> on 2017/12/25 02:18:00 UTC

[jira] [Commented] (CALCITE-2108) AggregateJoinTransposeRule fails when process aggregateCall above SqlSumEmptyIsZeroAggFunction without groupKeys

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

jingzhang commented on CALCITE-2108:
------------------------------------

[~julianhyde]. I've created a pull request https://github.com/apache/calcite/pull/591. Please have a look, thanks a lot.

> AggregateJoinTransposeRule fails when process aggregateCall above SqlSumEmptyIsZeroAggFunction without groupKeys
> ----------------------------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-2108
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2108
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: jingzhang
>            Assignee: Julian Hyde
>
> {code}
>    final HepProgram preProgram = new HepProgramBuilder()
>             .addRuleInstance(AggregateProjectMergeRule.INSTANCE)
>             .build();
>     final HepProgram program = new HepProgramBuilder()
>             .addRuleInstance(AggregateReduceFunctionsRule.INSTANCE)
>             .addRuleInstance(AggregateJoinTransposeRule.EXTENDED)
>             .build();
>     final String sql = "select sum(sal)\n"
>             + "from (select * from sales.emp where empno = 10) as e\n"
>             + "join sales.dept as d on e.job = d.name";
> {code}
> AggregateJoinTransposeRule fails when run the above sql, the exception is as following.  
> {code}
> java.lang.AssertionError: type mismatch:
> aggCall type:
> INTEGER NOT NULL
> inferred type:
> INTEGER
> 	at org.apache.calcite.util.Litmus$1.fail(Litmus.java:31)
> 	at org.apache.calcite.plan.RelOptUtil.eq(RelOptUtil.java:1838)
> 	at org.apache.calcite.rel.core.Aggregate.typeMatchesInferred(Aggregate.java:428)
> 	at org.apache.calcite.rel.core.Aggregate.<init>(Aggregate.java:161)
> 	at org.apache.calcite.rel.logical.LogicalAggregate.<init>(LogicalAggregate.java:65)
> 	at org.apache.calcite.rel.logical.LogicalAggregate.create_(LogicalAggregate.java:110)
> 	at org.apache.calcite.rel.logical.LogicalAggregate.create(LogicalAggregate.java:100)
> 	at org.apache.calcite.rel.core.RelFactories$AggregateFactoryImpl.createAggregate(RelFactories.java:213)
> 	at org.apache.calcite.tools.RelBuilder.aggregate(RelBuilder.java:1267)
> 	at org.apache.calcite.tools.RelBuilder.aggregate(RelBuilder.java:1825)
> 	at org.apache.calcite.rel.rules.AggregateJoinTransposeRule.onMatch(AggregateJoinTransposeRule.java:337)
> {code}
> *Notes*: This is different with the issue referred in https://issues.apache.org/jira/browse/CALCITE-2105. This question caused by  the SqlSplittableAggFunction of SqlSumEmptyIsZeroAggFunction is SumSplitter. If groupByKeys is empty, the aggregateCalls returnTypes of Sum is nullable, while the returnTypes of Sum0 is not nullable.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)