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

ReduceExpressionsRule requires planner to have an Executor

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.1.0-incubating
    • None
    • None

    Description

      ReduceExpressionsRule requires planner to have an Executor. If it does not, you get a stack trace like this:

      java.lang.NullPointerException
      	at org.apache.calcite.rel.rules.ReduceExpressionsRule.reduceExpressions(ReduceExpressionsRule.java:387)
      	at org.apache.calcite.rel.rules.ReduceExpressionsRule$3.onMatch(ReduceExpressionsRule.java:223)
      	at org.apache.calcite.plan.AbstractRelOptPlanner.fireRule(AbstractRelOptPlanner.java:326)
      	at org.apache.calcite.plan.hep.HepPlanner.applyRule(HepPlanner.java:515)
      	at org.apache.calcite.plan.hep.HepPlanner.applyRules(HepPlanner.java:393)
      	at org.apache.calcite.plan.hep.HepPlanner.executeInstruction(HepPlanner.java:285)
      	at org.apache.calcite.plan.hep.HepInstruction$RuleCollection.execute(HepInstruction.java:72)
      	at org.apache.calcite.plan.hep.HepPlanner.executeProgram(HepPlanner.java:207)
      	at org.apache.calcite.plan.hep.HepPlanner.findBestExp(HepPlanner.java:194)
      	at org.apache.hadoop.hive.ql.parse.CalcitePlanner$CalcitePlannerAction.hepPlan(CalcitePlanner.java:837)
      	at org.apache.hadoop.hive.ql.parse.CalcitePlanner$CalcitePlannerAction.applyPreJoinOrderingTransforms(CalcitePlanner.java:770)
      	at org.apache.hadoop.hive.ql.parse.CalcitePlanner$CalcitePlannerAction.apply(CalcitePlanner.java:701)
      	at org.apache.hadoop.hive.ql.parse.CalcitePlanner$CalcitePlannerAction.apply(CalcitePlanner.java:658)
      	at org.apache.calcite.tools.Frameworks$1.apply(Frameworks.java:109)
      	at org.apache.calcite.prepare.CalcitePrepareImpl.perform(CalcitePrepareImpl.java:715)
      	at org.apache.calcite.tools.Frameworks.withPrepare(Frameworks.java:145)
      	at org.apache.calcite.tools.Frameworks.withPlanner(Frameworks.java:105)
      	at org.apache.hadoop.hive.ql.parse.CalcitePlanner.getOptimizedAST(CalcitePlanner.java:568)
      	at org.apache.hadoop.hive.ql.parse.CalcitePlanner.genOPTree(CalcitePlanner.java:224)

      There is a workaround. Set the executor of the planner before invoking findBestExp. Set it on the planner of the cluster of the root RelNode (which is not necessarily the planner that is executing the rules):

      final RexExecutorImpl executor =
          new RexExecutorImpl(Schemas.createDataContext(null));
      rootRel.getCluster().getPlanner().setExecutor(executor);

      We should fix this by having the rule give a warning and return (doing nothing) if an executor is not set.

      Attachments

        Activity

          People

            julianhyde Julian Hyde
            julianhyde Julian Hyde
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: