Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-2278

AggregateJoinTransposeRule fails to split aggregate call if input contains an aggregate call and has distinct rows

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.17.0
    • Component/s: core
    • Labels:
      None

      Description

      For the following query:

      select A.job, B.mgr, A.deptno,
       max(B.hiredate1) as hiredate1, sum(B.comm1) as comm1
       from sales.emp as A
       join (select mgr, sal, max(hiredate) as hiredate1,
       sum(comm) as comm1 from sales.emp group by mgr, sal) as B
       on A.sal=B.sal
       group by A.job, B.mgr, A.deptno

       

      Exception is thrown out: 

      java.lang.IndexOutOfBoundsException: index (7) must be less than size (6)
      at com.google.common.base.Preconditions.checkElementIndex(Preconditions.java:310)
       at com.google.common.base.Preconditions.checkElementIndex(Preconditions.java:293)
       at com.google.common.collect.RegularImmutableList.get(RegularImmutableList.java:67)
       at org.apache.calcite.sql.SqlSplittableAggFunction$AbstractSumSplitter.topSplit(SqlSplittableAggFunction.java:246)
       at org.apache.calcite.rel.rules.AggregateJoinTransposeRule.onMatch(AggregateJoinTransposeRule.java:332)
       at org.apache.calcite.plan.AbstractRelOptPlanner.fireRule(AbstractRelOptPlanner.java:317)
       at org.apache.calcite.plan.hep.HepPlanner.applyRule(HepPlanner.java:556)
       at org.apache.calcite.plan.hep.HepPlanner.applyRules(HepPlanner.java:415)
       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:170)
       
      

       

        Attachments

          Activity

            People

            • Assignee:
              julianhyde Julian Hyde
              Reporter:
              hyuan Haisheng Yuan
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: