DRILL-686: Verify the operands while extracting projects that can be pushed 
into a scan


Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/508cb5de
Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/508cb5de
Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/508cb5de

Branch: refs/heads/master
Commit: 508cb5dea9deb66661267abd174d54db99dc6bfa
Parents: 49d5333
Author: Aditya Kishore <[email protected]>
Authored: Sat May 10 18:07:10 2014 -0700
Committer: Jacques Nadeau <[email protected]>
Committed: Mon May 12 11:46:19 2014 -0700

----------------------------------------------------------------------
 .../drill/exec/planner/physical/PrelUtil.java     | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/508cb5de/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/PrelUtil.java
----------------------------------------------------------------------
diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/PrelUtil.java
 
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/PrelUtil.java
index e98b970..bdc8b31 100644
--- 
a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/PrelUtil.java
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/PrelUtil.java
@@ -41,7 +41,6 @@ import org.eigenbase.rex.RexCall;
 import org.eigenbase.rex.RexInputRef;
 import org.eigenbase.rex.RexLiteral;
 import org.eigenbase.rex.RexNode;
-import org.eigenbase.rex.RexOver;
 import org.eigenbase.rex.RexVisitorImpl;
 
 import com.beust.jcommander.internal.Lists;
@@ -144,12 +143,17 @@ public class PrelUtil {
     @Override
     public PathSegment visitCall(RexCall call) {
       if ("ITEM".equals(call.getOperator().getName())) {
-        return call.operands.get(0).accept(this)
-            .cloneWithNewChild(convertLiteral((RexLiteral) 
call.operands.get(1)));
-      }
-      // else
-      for (RexNode operand : call.operands) {
-        addColumn(operand.accept(this));
+        PathSegment mapOrArray = call.operands.get(0).accept(this);
+        if (mapOrArray != null) {
+          if (call.operands.get(1) instanceof RexLiteral) {
+            return mapOrArray.cloneWithNewChild(convertLiteral((RexLiteral) 
call.operands.get(1)));
+          }
+          return mapOrArray;
+        }
+      } else {
+        for (RexNode operand : call.operands) {
+          addColumn(operand.accept(this));
+        }
       }
       return null;
     }

Reply via email to