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

Danny Chan edited comment on CALCITE-3076 at 5/20/19 1:59 PM:
--------------------------------------------------------------

[~anha] I have got the reason, it is not because the LogicalValues, it is 
because we figured wrong mappings for under agg calls when the under aggregate 
key is unique. Thanks for your test case :)


was (Author: danny0405):
[~anha] I have got the reason, it is not because the LogicalValues, it is 
because we figured wrong mappings for under agg calls when the under aggregate 
key is unique.

> AggregateJoinTransposeRule throws error for unique under aggregate keys when 
> generating merged calls
> ----------------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-3076
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3076
>             Project: Calcite
>          Issue Type: Bug
>    Affects Versions: 1.19.0
>            Reporter: Anton Haidai
>            Assignee: Danny Chan
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> RelOptRulesTest:
> {code}
>   @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();
>   }
> {code}
> Error:
> {code}
> 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)
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to