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

AggregateJoinTransposeRule throws error for unique under aggregate keys when generating merged calls

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.19.0
    • Fix Version/s: 1.20.0
    • Component/s: None

      Description

      RelOptRulesTest:

        @Test public void testPushAggregateThroughJoinOnEmptyLogicalValuesError() {
          final HepProgram preProgram = new HepProgramBuilder()
              .addRuleInstance(AggregateProjectMergeRule.INSTANCE)
              .addRuleInstance(ReduceExpressionsRule.FilterReduceExpressionsRule.FILTER_INSTANCE)
              .build();
      
          final HepProgram program = new HepProgramBuilder()
              .addRuleInstance(AggregateJoinTransposeRule.EXTENDED)
              .build();
      
          final String sql =
              "select count(*) volume, sum(C1.sal) C1_sum_sal " +
              "from (select sal, ename from sales.emp where 1=2) C1 " +
              "inner join (select ename from sales.emp) C2   " +
              "on C1.ename = C2.ename ";
          sql(sql).withPre(preProgram).with(program).check();
        }
      

      Error:

      java.lang.IllegalArgumentException: Cannot infer return type for *; operand types: [VARCHAR(20), BIGINT]
      
      	at org.apache.calcite.sql.SqlOperator.inferReturnType(SqlOperator.java:474)
      	at org.apache.calcite.rex.RexBuilder.deriveReturnType(RexBuilder.java:276)
      	at org.apache.calcite.rex.RexBuilder.makeCall(RexBuilder.java:250)
      	at org.apache.calcite.sql.SqlSplittableAggFunction$AbstractSumSplitter.topSplit(SqlSplittableAggFunction.java:298)
      	at org.apache.calcite.rel.rules.AggregateJoinTransposeRule.onMatch(AggregateJoinTransposeRule.java:342)
      	at org.apache.calcite.plan.AbstractRelOptPlanner.fireRule(AbstractRelOptPlanner.java:319)
      	at org.apache.calcite.plan.hep.HepPlanner.applyRule(HepPlanner.java:559)
      	at org.apache.calcite.plan.hep.HepPlanner.applyRules(HepPlanner.java:418)
      	at org.apache.calcite.plan.hep.HepPlanner.executeInstruction(HepPlanner.java:255)
      	at org.apache.calcite.plan.hep.HepInstruction$RuleInstance.execute(HepInstruction.java:127)
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                danny0405 Danny Chen
                Reporter:
                anha Anton Haidai
              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m