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 2018/01/11 07:36:00 UTC

[jira] [Resolved] (CALCITE-2124) AggregateExpandDistinctAggregatesRule should make SUM nullable if there is no GROUP BY

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

Julian Hyde resolved CALCITE-2124.
----------------------------------
       Resolution: Fixed
    Fix Version/s: 1.16.0

Fixed in [1c7f690d|http://git-wip-us.apache.org/repos/asf/calcite/commit/1c7f690d]; thanks for the PR, [~godfreyhe]!

> AggregateExpandDistinctAggregatesRule should make SUM nullable if there is no GROUP BY
> --------------------------------------------------------------------------------------
>
>                 Key: CALCITE-2124
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2124
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.15.0
>            Reporter: godfrey he
>            Assignee: Julian Hyde
>             Fix For: 1.16.0
>
>
> AggregateExpandDistinctAggregatesRule should make SUM nullable if there is no GROUP BY. The following test gives aggCall type mismatch error:
> {code}
> @Test public void testDistinctCountWithoutGroupBy() {
>      final HepProgram program = HepProgram.builder()
>         .addRuleInstance(AggregateExpandDistinctAggregatesRule.INSTANCE)
>         .addRuleInstance(AggregateProjectMergeRule.INSTANCE)
>         .build();
>     checkPlanning(program,
>         "select max(deptno), count(distinct ename) from sales.emp");
>   }
> {code}
> exception:
> {code}
> java.lang.AssertionError: type mismatch:
> aggCall type:
> INTEGER
> inferred type:
> INTEGER NOT NULL
> 	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:1268)
> 	at org.apache.calcite.tools.RelBuilder.aggregate(RelBuilder.java:1840)
> 	at org.apache.calcite.rel.rules.AggregateExpandDistinctAggregatesRule.rewriteUsingGroupingSets(AggregateExpandDistinctAggregatesRule.java:413)
> 	at org.apache.calcite.rel.rules.AggregateExpandDistinctAggregatesRule.onMatch(AggregateExpandDistinctAggregatesRule.java:172)
> 	at org.apache.calcite.plan.AbstractRelOptPlanner.fireRule(AbstractRelOptPlanner.java:317)
> 	at org.apache.calcite.plan.hep.HepPlanner.applyRule(HepPlanner.java:508)
> 	at org.apache.calcite.plan.hep.HepPlanner.applyRules(HepPlanner.java:387)
> 	at org.apache.calcite.plan.hep.HepPlanner.executeInstruction(HepPlanner.java:252)
> 	at org.apache.calcite.plan.hep.HepInstruction$RuleInstance.execute(HepInstruction.java:127)
> 	at org.apache.calcite.plan.hep.HepPlanner.executeProgram(HepPlanner.java:211)
> 	at org.apache.calcite.plan.hep.HepPlanner.findBestExp(HepPlanner.java:198)
> 	at org.apache.calcite.test.RelOptTestBase.checkPlanning(RelOptTestBase.java:165)
> 	at org.apache.calcite.test.RelOptTestBase.checkPlanning(RelOptTestBase.java:120)
> 	at org.apache.calcite.test.RelOptTestBase.checkPlanning(RelOptTestBase.java:95)
> 	at org.apache.calcite.test.RelOptTestBase.checkPlanning(RelOptTestBase.java:84)
> 	at org.apache.calcite.test.RelOptRulesTest.testDistinctCountWithoutGroupBy(RelOptRulesTest.java:761)
> {code}



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