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

VolcanoPlanner CannotPlanException: best rel is null even though there is an option with non-infinite cost

    XMLWordPrintableJSON

    Details

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

      Description

      The problem can be reproduced by adding this test to PlannerTest.java:

        @Test public void testCannotPlanException() throws Exception {
          RelBuilder builder = RelBuilder.create(RelBuilderTest.config().build());
          RuleSet ruleSet =
              RuleSets.ofList(
                  //EnumerableRules.ENUMERABLE_JOIN_RULE, // with this rule it works!
                  JoinToCorrelateRule.INSTANCE,
                  EnumerableRules.ENUMERABLE_CORRELATE_RULE,
                  EnumerableRules.ENUMERABLE_PROJECT_RULE,
                  EnumerableRules.ENUMERABLE_FILTER_RULE,
                  EnumerableRules.ENUMERABLE_SORT_RULE,
                  EnumerableRules.ENUMERABLE_UNION_RULE,
                  EnumerableRules.ENUMERABLE_TABLE_SCAN_RULE);
      
          builder
              .scan("EMP")
              .scan("EMP")
              .union(true)
      
              .scan("EMP")
              .scan("EMP")
              .union(true)
      
              .join(
                  JoinRelType.INNER,
                  builder.equals(
                      builder.field(2, 0, "DEPTNO"),
                      builder.field(2, 1, "EMPNO")));
      
          RelNode relNode = builder.build();
          RelOptPlanner planner = relNode.getCluster().getPlanner();
          Program program = Programs.of(ruleSet);
          RelTraitSet toTraits = relNode.getTraitSet()
              .replace(EnumerableConvention.INSTANCE);
          RelNode output = program.run(planner, relNode, toTraits,
              ImmutableList.of(), ImmutableList.of());
          String outputStr = toString(output);
        }
      

      Running this test causes the following exception (full stack trace attached):

      org.apache.calcite.plan.RelOptPlanner$CannotPlanException: There are not enough rules to produce a node with desired properties: convention=ENUMERABLE, sort=[]. All the inputs have relevant nodes, however the cost is still infinite.
      Root: rel#13:Subset#2.ENUMERABLE.[]
      

      The last part of the message (All the inputs have relevant nodes, however the cost is still infinite) seems relevant, because we can see that rel#13's best is null, and it should be rel#21 (which has a non-infinite cost):

      rel#13:Subset#2.ENUMERABLE.[], best=null, importance=1.0
          rel#14:AbstractConverter.ENUMERABLE.[](input=RelSubset#12, convention=ENUMERABLE, sort=[]), rowcount=117.6, cumulative cost={inf}
          rel#21:EnumerableCorrelate.ENUMERABLE.[](left=RelSubset#19, right=RelSubset#20, correlation=$cor0, joinType=inner, requiredColumns={7}), rowcount=1.0, cumulative cost={1770.6000000000001 rows, 2466.0 cpu, 0.0 io}
      

        Attachments

        1. Diagram.png
          26 kB
          Ruben Q L
        2. Graphviz.png
          310 kB
          Ruben Q L
        3. logsTRACE.txt
          96 kB
          Ruben Q L
        4. stackTrace.txt
          9 kB
          Ruben Q L

          Issue Links

            Activity

              People

              • Assignee:
                rubenql Ruben Q L
                Reporter:
                rubenql Ruben Q L
              • Votes:
                0 Vote for this issue
                Watchers:
                5 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 - 0.5h
                  0.5h