You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by am...@apache.org on 2014/12/17 21:31:38 UTC

[3/3] drill git commit: DRILL-1828: In ProjectRecordBatch, add a case for expression classification

DRILL-1828: In ProjectRecordBatch, add a case for expression classification


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

Branch: refs/heads/master
Commit: d2c58291846f2b39fd2ef42d4b8c526484d5992b
Parents: 089ebe1
Author: Hsuan-Yi Chu <hs...@usc.edu>
Authored: Tue Nov 18 17:22:07 2014 -0800
Committer: Aman Sinha <as...@maprtech.com>
Committed: Wed Dec 17 12:30:06 2014 -0800

----------------------------------------------------------------------
 .../physical/impl/project/ProjectRecordBatch.java   | 16 +++++++++++++++-
 .../test/java/org/apache/drill/TestStarQueries.java |  6 ++++++
 2 files changed, 21 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/d2c58291/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/project/ProjectRecordBatch.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/project/ProjectRecordBatch.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/project/ProjectRecordBatch.java
index 865c4fd..fa983aa 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/project/ProjectRecordBatch.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/project/ProjectRecordBatch.java
@@ -320,6 +320,7 @@ public class ProjectRecordBatch extends AbstractSingleRecordBatch<Project> {
         classifyExpr(namedExpression, incoming, result);
 
         if (result.isStar) {
+          // The parameter value indicates which wildcard we are processing now
           Integer value = result.prefixMap.get(result.prefix);
           if (value != null && value.intValue() == 1) {
             int k = 0;
@@ -550,12 +551,14 @@ public class ProjectRecordBatch extends AbstractSingleRecordBatch<Project> {
       result.prefix = exprPrefix;
     }
 
+    boolean exprIsFirstWildcard = false;
     if (exprContainsStar) {
       result.isStar = true;
       Integer value = (Integer) result.prefixMap.get(exprPrefix);
       if (value == null) {
         Integer n = 1;
         result.prefixMap.put(exprPrefix, n);
+        exprIsFirstWildcard = true;
       } else {
         Integer n = value + 1;
         result.prefixMap.put(exprPrefix, n);
@@ -585,7 +588,7 @@ public class ProjectRecordBatch extends AbstractSingleRecordBatch<Project> {
       }
     }
     // input and output are the same
-    else if (expr.getPath().equals(ref.getPath())) {
+    else if (expr.getPath().equals(ref.getPath()) && (!exprContainsStar || exprIsFirstWildcard)) {
       if (exprContainsStar && exprHasPrefix) {
         assert exprPrefix != null;
 
@@ -637,6 +640,17 @@ public class ProjectRecordBatch extends AbstractSingleRecordBatch<Project> {
         }
       }
     }
+
+    // input is wildcard and it is not the first wildcard
+    else if(exprIsStar) {
+      result.outputNames = Lists.newArrayList();
+      for (VectorWrapper<?> wrapper : incoming) {
+        ValueVector vvIn = wrapper.getValueVector();
+        String incomingName = vvIn.getField().getPath().getRootSegment().getPath();
+        addToResultMaps(incomingName, result, true); // allow dups since this is likely top-level project
+      }
+    }
+
     // only the output has prefix
     else if (!exprHasPrefix && refHasPrefix) {
       result.outputNames = Lists.newArrayList();

http://git-wip-us.apache.org/repos/asf/drill/blob/d2c58291/exec/java-exec/src/test/java/org/apache/drill/TestStarQueries.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/TestStarQueries.java b/exec/java-exec/src/test/java/org/apache/drill/TestStarQueries.java
index 07ba9f8..9ce2d8c 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/TestStarQueries.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/TestStarQueries.java
@@ -23,6 +23,12 @@ import org.apache.drill.exec.rpc.RpcException;
 public class TestStarQueries extends BaseTestQuery{
   static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestStarQueries.class);
 
+  @Test // see DRILL-1828
+  public void testSelStarMultipleStars() throws Exception {
+    test("select *, * from cp.`employee.json`;");
+    test("select *, * from cp.`employee.json` limit 2;");
+  }
+
   @Test // see DRILL-1825
   public void testSelStarWithAdditionalColumnLimit() throws Exception {
     test("select *, first_name, *, last_name from cp.`employee.json` limit 2;");