Repository: calcite
Updated Branches:
  refs/heads/master 60777142e -> 0d996daf5


[CALCITE-1691] ClassCastException in RelOptUtil.containsNullableFields, 
attempting to convert executor to RexExecutorImpl


Project: http://git-wip-us.apache.org/repos/asf/calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/calcite/commit/46672b41
Tree: http://git-wip-us.apache.org/repos/asf/calcite/tree/46672b41
Diff: http://git-wip-us.apache.org/repos/asf/calcite/diff/46672b41

Branch: refs/heads/master
Commit: 46672b41fdb0c0aedb30d0ec7158d138d36222d5
Parents: 785c2fb
Author: Julian Hyde <[email protected]>
Authored: Fri Mar 10 11:24:30 2017 -0800
Committer: Julian Hyde <[email protected]>
Committed: Fri Mar 10 12:02:12 2017 -0800

----------------------------------------------------------------------
 .../java/org/apache/calcite/plan/RelOptUtil.java    | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/calcite/blob/46672b41/core/src/main/java/org/apache/calcite/plan/RelOptUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/plan/RelOptUtil.java 
b/core/src/main/java/org/apache/calcite/plan/RelOptUtil.java
index b5d3cb3..7655290 100644
--- a/core/src/main/java/org/apache/calcite/plan/RelOptUtil.java
+++ b/core/src/main/java/org/apache/calcite/plan/RelOptUtil.java
@@ -62,6 +62,7 @@ import org.apache.calcite.rex.LogicVisitor;
 import org.apache.calcite.rex.RexBuilder;
 import org.apache.calcite.rex.RexCall;
 import org.apache.calcite.rex.RexCorrelVariable;
+import org.apache.calcite.rex.RexExecutor;
 import org.apache.calcite.rex.RexExecutorImpl;
 import org.apache.calcite.rex.RexFieldAccess;
 import org.apache.calcite.rex.RexInputRef;
@@ -3320,6 +3321,11 @@ public abstract class RelOptUtil {
    * Determines whether any of the fields in a given relational expression may
    * contain null values, taking into account constraints on the field types 
and
    * also deduced predicates.
+   *
+   * <p>The method is cautious: It may sometimes return {@code true} when the
+   * actual answer is {@code false}. In particular, it does this when there
+   * is no executor, or the executor is not a sub-class of
+   * {@link RexExecutorImpl}.
    */
   private static boolean containsNullableFields(RelNode r) {
     final RexBuilder rexBuilder = r.getCluster().getRexBuilder();
@@ -3343,10 +3349,14 @@ public abstract class RelOptUtil {
       // declared NULL are really NOT NULL.
       return true;
     }
-    RexExecutorImpl rexImpl =
-        (RexExecutorImpl) r.getCluster().getPlanner().getExecutor();
+    final RexExecutor executor = r.getCluster().getPlanner().getExecutor();
+    if (!(executor instanceof RexExecutorImpl)) {
+      // Cannot proceed without an executor.
+      return true;
+    }
     final RexImplicationChecker checker =
-        new RexImplicationChecker(rexBuilder, rexImpl, rowType);
+        new RexImplicationChecker(rexBuilder, (RexExecutorImpl) executor,
+            rowType);
     final RexNode first =
         RexUtil.composeConjunction(rexBuilder, predicates.pulledUpPredicates,
             false);

Reply via email to