[ 
https://issues.apache.org/jira/browse/CALCITE-2108?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Drew Foulks updated CALCITE-2108:
---------------------------------
    Reporter: Jing Zhang  (was: Jing Zhang)

> 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: Jing Zhang
>            Assignee: Julian Hyde
>            Priority: Major
>             Fix For: 1.16.0
>
>
> {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
(v8.20.1#820001)

Reply via email to