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

Ruben Q L commented on CALCITE-4261:
------------------------------------

The problem seems to be that, the second time 
{{EnumerableBatchNestedLoopJoinRule}} gets applied, it mixes the correlated 
variables and applies a visitor transformation on the wrong correlated 
variable. 

> Join with three tables causes IllegalArgumentException in 
> EnumerableBatchNestedLoopJoinRule
> -------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-4261
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4261
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.25.0
>            Reporter: Ruben Q L
>            Assignee: Ruben Q L
>            Priority: Major
>             Fix For: 1.26.0
>
>
> Issue can be reproduced with the following test (to be added in 
> {{EnumerableBatchNestedLoopJoinTest}}):
> {code}
>   @Test void doubleInnerBatchJoinTestSQL() {
>     tester(false, new JdbcTest.HrSchema())
>         .query("select e.name, d.name as dept, l.name as location "
>             + "from emps e join depts d on d.deptno <> e.salary "
>             + "join locations l on e.empid <> l.empid and d.deptno = l.empid")
>         .withHook(Hook.PLANNER, (Consumer<RelOptPlanner>) planner -> {
>           planner.removeRule(EnumerableRules.ENUMERABLE_CORRELATE_RULE);
>           
> planner.addRule(EnumerableRules.ENUMERABLE_BATCH_NESTED_LOOP_JOIN_RULE);
>         })
>         .explainContains("EnumerableBatchNestedLoopJoin")
>         .returnsUnordered("name=Bill; dept=Sales; location=San Francisco",
>             "name=Eric; dept=Sales; location=San Francisco",
>             "name=Sebastian; dept=Sales; location=San Francisco",
>             "name=Theodore; dept=Sales; location=San Francisco");
>   }
> {code}
> Which causes:
> {code}
> Error while executing SQL "explain plan for select e.name, d.name as dept, 
> l.name as location from emps e join depts d on d.deptno <> e.salary join 
> locations l on e.empid <> l.empid and d.deptno = l.empid"
> ...
> Caused by: java.lang.RuntimeException: Error while applying rule 
> EnumerableBatchNestedLoopJoinRule,
> ...
> Caused by: java.lang.IllegalArgumentException: Field #0: empid JavaType(int) 
> does not exist for expression $cor1801
>       at 
> com.google.common.base.Preconditions.checkArgument(Preconditions.java:122)
> ...
>       at 
> org.apache.calcite.adapter.enumerable.EnumerableBatchNestedLoopJoinRule.onMatch(EnumerableBatchNestedLoopJoinRule.java:127)
>       at 
> org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:229)
> ...
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to