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

IndexOutOfBoundsException in FixNullabilityShuttle when using FilterIntoJoinRule

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.21.0
    • Fix Version/s: 1.22.0
    • Component/s: None

      Description

      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
       
       

        Attachments

        1. TestCalcite.java
          9 kB
          Amit Chavan

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                achavan1@gmail.com Amit Chavan
              • Votes:
                0 Vote for this issue
                Watchers:
                6 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 - 4h
                  4h