You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by pa...@apache.org on 2015/02/18 06:30:14 UTC

[2/3] drill git commit: DRILL-2254: use parent field while adding a child vector into a repeated list

DRILL-2254: use parent field while adding a child vector into a repeated list


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

Branch: refs/heads/master
Commit: d2831ba7aa3caebae99f4571d683b5ee5ba44148
Parents: ab4d799
Author: Hanifi Gunes <hg...@maprtech.com>
Authored: Tue Feb 17 12:20:01 2015 -0800
Committer: Parth Chandra <pc...@maprtech.com>
Committed: Tue Feb 17 17:04:23 2015 -0800

----------------------------------------------------------------------
 .../exec/vector/complex/RepeatedListVector.java |  2 +-
 .../exec/physical/impl/flatten/TestFlatten.java | 39 ++++++++++++++++++++
 .../flatten/drill-2254-result-mix.json          |  9 +++++
 .../flatten/drill-2254-result-multi.json        |  3 ++
 .../flatten/drill-2254-result-single.json       |  3 ++
 5 files changed, 55 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/d2831ba7/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/RepeatedListVector.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/RepeatedListVector.java b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/RepeatedListVector.java
index d09dc55..131f2a3 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/RepeatedListVector.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/RepeatedListVector.java
@@ -388,7 +388,7 @@ public class RepeatedListVector extends AbstractContainerVector implements Repea
     Preconditions.checkArgument(name == null);
 
     if(vector == null){
-      final MaterializedField child =  MaterializedField.create(SchemaPath.getSimplePath("").getUnindexedArrayChild(), type);
+      final MaterializedField child =  MaterializedField.create(getField().getPath().getUnindexedArrayChild(), type);
       vector = TypeHelper.getNewVector(child, allocator, callBack);
       setVector(vector);
       if (callBack != null) {

http://git-wip-us.apache.org/repos/asf/drill/blob/d2831ba7/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/flatten/TestFlatten.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/flatten/TestFlatten.java b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/flatten/TestFlatten.java
index f9eb2c2..b56df84 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/flatten/TestFlatten.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/flatten/TestFlatten.java
@@ -20,6 +20,7 @@ package org.apache.drill.exec.physical.impl.flatten;
 import static org.junit.Assert.assertEquals;
 
 import org.apache.drill.BaseTestQuery;
+import org.apache.drill.exec.proto.UserBitShared;
 import org.junit.Ignore;
 import org.junit.Test;
 
@@ -202,4 +203,42 @@ public class TestFlatten extends BaseTestQuery {
     test("select flatten(sub.fk.`value`) from (select flatten(kvgen(map)) fk from cp.`/store/json/nested_repeated_map.json`) sub");
   }
 
+
+  @Test //DRILL-2254
+  public void testSingleFlattenFromNestedRepeatedList() throws Exception {
+    final String query = "select t.uid, flatten(t.odd) odd from cp.`project/complex/a.json` t";
+
+    testBuilder()
+        .sqlQuery(query)
+        .unOrdered()
+        .jsonBaselineFile("flatten/drill-2254-result-single.json")
+        .build()
+        .run();
+  }
+
+  @Test //DRILL-2254 supplementary
+  public void testMultiFlattenFromNestedRepeatedList() throws Exception {
+    final String query = "select t.uid, flatten(flatten(t.odd)) odd from cp.`project/complex/a.json` t";
+
+    testBuilder()
+        .sqlQuery(query)
+        .unOrdered()
+        .jsonBaselineFile("flatten/drill-2254-result-multi.json")
+        .build()
+        .run();
+  }
+
+  @Test //DRILL-2254 supplementary
+  public void testSingleMultiFlattenFromNestedRepeatedList() throws Exception {
+    final String query = "select t.uid, flatten(t.odd) once, flatten(flatten(t.odd)) twice from cp.`project/complex/a.json` t";
+
+    testBuilder()
+        .sqlQuery(query)
+        .unOrdered()
+        .jsonBaselineFile("flatten/drill-2254-result-mix.json")
+        .build()
+        .run();
+  }
+
+
 }

http://git-wip-us.apache.org/repos/asf/drill/blob/d2831ba7/exec/java-exec/src/test/resources/flatten/drill-2254-result-mix.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/flatten/drill-2254-result-mix.json b/exec/java-exec/src/test/resources/flatten/drill-2254-result-mix.json
new file mode 100644
index 0000000..8c4d481
--- /dev/null
+++ b/exec/java-exec/src/test/resources/flatten/drill-2254-result-mix.json
@@ -0,0 +1,9 @@
+{"uid": 1, "once": [1], "twice": 1}
+{"uid": 1, "once": [1], "twice": 3}
+{"uid": 1, "once": [1], "twice": 5}
+{"uid": 1, "once": [3], "twice": 1}
+{"uid": 1, "once": [3], "twice": 3}
+{"uid": 1, "once": [3], "twice": 5}
+{"uid": 1, "once": [5], "twice": 1}
+{"uid": 1, "once": [5], "twice": 3}
+{"uid": 1, "once": [5], "twice": 5}

http://git-wip-us.apache.org/repos/asf/drill/blob/d2831ba7/exec/java-exec/src/test/resources/flatten/drill-2254-result-multi.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/flatten/drill-2254-result-multi.json b/exec/java-exec/src/test/resources/flatten/drill-2254-result-multi.json
new file mode 100644
index 0000000..b04375a
--- /dev/null
+++ b/exec/java-exec/src/test/resources/flatten/drill-2254-result-multi.json
@@ -0,0 +1,3 @@
+{"uid": 1, "odd": 1}
+{"uid": 1, "odd": 3}
+{"uid": 1, "odd": 5}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/drill/blob/d2831ba7/exec/java-exec/src/test/resources/flatten/drill-2254-result-single.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/flatten/drill-2254-result-single.json b/exec/java-exec/src/test/resources/flatten/drill-2254-result-single.json
new file mode 100644
index 0000000..ffd748f
--- /dev/null
+++ b/exec/java-exec/src/test/resources/flatten/drill-2254-result-single.json
@@ -0,0 +1,3 @@
+{"uid": 1, "odd": [1]}
+{"uid": 1, "odd": [3]}
+{"uid": 1, "odd": [5]}
\ No newline at end of file