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

ShuMing Li edited comment on CALCITE-3347 at 9/16/19 2:55 AM:
--------------------------------------------------------------

[~julianhyde]  I add a simple test in `JdbcTest.java` as below(no bind 
variables):
{code:java}
@Test public void testSemiJoin() {
  CalciteAssert.that()
      .with(CalciteAssert.Config.JDBC_FOODMART)
      .query("select *\n"
          + " from \"foodmart\".\"employee\""
          + " where \"employee_id\" = 1 and \"last_name\" in"
          + " (select \"last_name\" from \"foodmart\".\"employee\" where 
\"employee_id\" = 2)")
      .runs();
}
{code}
 

The same exception is thrown, So I doubt this maybe a bug in a RelOptRule.
{code:java}
Caused by: java.lang.IndexOutOfBoundsException: index (18) must be less than 
size (17)Caused by: java.lang.IndexOutOfBoundsException: index (18) must be 
less than size (17) 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 
com.google.common.collect.Lists$TransformingRandomAccessList.get(Lists.java:627)
 at 
org.apache.calcite.rex.RexUtil$FixNullabilityShuttle.visitInputRef(RexUtil.java:2529)
 at 
org.apache.calcite.rex.RexUtil$FixNullabilityShuttle.visitInputRef(RexUtil.java:2518)
 at org.apache.calcite.rex.RexInputRef.accept(RexInputRef.java:112) at 
org.apache.calcite.rex.RexShuttle.visitList(RexShuttle.java:149) at 
org.apache.calcite.rex.RexShuttle.visitCall(RexShuttle.java:101) at 
org.apache.calcite.rex.RexShuttle.visitCall(RexShuttle.java:34) at 
org.apache.calcite.rex.RexCall.accept(RexCall.java:191) at 
org.apache.calcite.rex.RexShuttle.apply(RexShuttle.java:277) at 
org.apache.calcite.rex.RexShuttle.mutate(RexShuttle.java:239) at 
org.apache.calcite.rex.RexShuttle.apply(RexShuttle.java:257) at 
org.apache.calcite.rex.RexUtil.fixUp(RexUtil.java:1635) at 
org.apache.calcite.rel.rules.FilterJoinRule.perform(FilterJoinRule.java:288) at 
org.apache.calcite.rel.rules.FilterJoinRule$FilterIntoJoinRule.onMatch(FilterJoinRule.java:387)
 at 
org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:208)
 ... 41 more
{code}


was (Author: lishuming):
[~julianhyde]  I add a simple test in `JdbcTest.java` as below(no bind 
variables):
{code:java}
// code placeholder
@Test public void testSemiJoin2() {
  CalciteAssert.that()
      .with(CalciteAssert.Config.JDBC_FOODMART)
      .query("select *\n"
          + " from \"foodmart\".\"employee\""
          + " where \"employee_id\" = 1 and \"last_name\" in"
          + " (select \"last_name\" from \"foodmart\".\"employee\" where 
\"employee_id\" = 2)")
      .runs();
}
{code}
 

The same exception is thrown, So I doubt this maybe a bug in a RelOptRule.
{code:java}
Caused by: java.lang.IndexOutOfBoundsException: index (18) must be less than 
size (17)Caused by: java.lang.IndexOutOfBoundsException: index (18) must be 
less than size (17) 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 
com.google.common.collect.Lists$TransformingRandomAccessList.get(Lists.java:627)
 at 
org.apache.calcite.rex.RexUtil$FixNullabilityShuttle.visitInputRef(RexUtil.java:2529)
 at 
org.apache.calcite.rex.RexUtil$FixNullabilityShuttle.visitInputRef(RexUtil.java:2518)
 at org.apache.calcite.rex.RexInputRef.accept(RexInputRef.java:112) at 
org.apache.calcite.rex.RexShuttle.visitList(RexShuttle.java:149) at 
org.apache.calcite.rex.RexShuttle.visitCall(RexShuttle.java:101) at 
org.apache.calcite.rex.RexShuttle.visitCall(RexShuttle.java:34) at 
org.apache.calcite.rex.RexCall.accept(RexCall.java:191) at 
org.apache.calcite.rex.RexShuttle.apply(RexShuttle.java:277) at 
org.apache.calcite.rex.RexShuttle.mutate(RexShuttle.java:239) at 
org.apache.calcite.rex.RexShuttle.apply(RexShuttle.java:257) at 
org.apache.calcite.rex.RexUtil.fixUp(RexUtil.java:1635) at 
org.apache.calcite.rel.rules.FilterJoinRule.perform(FilterJoinRule.java:288) at 
org.apache.calcite.rel.rules.FilterJoinRule$FilterIntoJoinRule.onMatch(FilterJoinRule.java:387)
 at 
org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:208)
 ... 41 more
{code}

> IndexOutOfBoundsException in FixNullabilityShuttle when using 
> FilterIntoJoinRule
> --------------------------------------------------------------------------------
>
>                 Key: CALCITE-3347
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3347
>             Project: Calcite
>          Issue Type: Bug
>    Affects Versions: 1.21.0
>            Reporter: Amit Chavan
>            Priority: Major
>         Attachments: TestCalcite.java
>
>
> I am reporting a bug that happens in calcite 1.21 release. I have a query as 
> below 
>  String query = "SELECT * FROM tblspace1.tsql where n1=? and k1 in (SELECT k1 
> FROM tblspace1.tsql where n1=?)";
>   
>  I am also attaching the unit test to reproduce this issue.  
>   
>  The filterJoinRule throws an exception –
>  java.lang.RuntimeException: Error while applying rule 
> FilterJoinRule:FilterJoinRule:filter, args 
> [rel#39:EnumerableFilter.ENUMERABLE.[](input=RelSubset#38,condition==($1, 
> ?0)), 
> rel#176:EnumerableHashJoin.ENUMERABLE.[](left=RelSubset#17,right=RelSubset#73,condition==($0,
>  $3),joinType=semi)]
>  at 
> org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:235)
>  at 
> org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:631)
>  at org.apache.calcite.TestCalcite.testQuery(TestCalcite.java:199)
>  at org.apache.calcite.TestCalcite.problem_with_1_21(TestCalcite.java:256)
>  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>  at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>  at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>  at java.lang.reflect.Method.invoke(Method.java:497)
>  at 
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
>  at 
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
>  at 
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
>  at 
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
>  at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
>  at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
>  at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
>  at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
>  at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
>  at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
>  at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
>  at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
>  at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
>  at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
>  at 
> com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
>  at 
> com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
>  at 
> com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
>  at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
>  Caused by: java.lang.IndexOutOfBoundsException: index (3) must be less than 
> size (3)
>  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 
> com.google.common.collect.Lists$TransformingRandomAccessList.get(Lists.java:627)
>  at 
> org.apache.calcite.rex.RexUtil$FixNullabilityShuttle.visitInputRef(RexUtil.java:2529)
>  at 
> org.apache.calcite.rex.RexUtil$FixNullabilityShuttle.visitInputRef(RexUtil.java:2518)
>  at org.apache.calcite.rex.RexInputRef.accept(RexInputRef.java:112)
>  at org.apache.calcite.rex.RexShuttle.visitList(RexShuttle.java:149)
>  at org.apache.calcite.rex.RexShuttle.visitCall(RexShuttle.java:101)
>  at org.apache.calcite.rex.RexShuttle.visitCall(RexShuttle.java:34)
>  at org.apache.calcite.rex.RexCall.accept(RexCall.java:191)
>  at org.apache.calcite.rex.RexShuttle.apply(RexShuttle.java:277)
>  at org.apache.calcite.rex.RexShuttle.mutate(RexShuttle.java:239)
>  at org.apache.calcite.rex.RexShuttle.apply(RexShuttle.java:257)
>  at org.apache.calcite.rex.RexUtil.fixUp(RexUtil.java:1635)
>  at 
> org.apache.calcite.rel.rules.FilterJoinRule.perform(FilterJoinRule.java:284)
>  at 
> org.apache.calcite.rel.rules.FilterJoinRule$FilterIntoJoinRule.onMatch(FilterJoinRule.java:383)
>  at 
> org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:208)
>  ... 25 more
>   
>   



--
This message was sent by Atlassian Jira
(v8.3.2#803003)

Reply via email to