You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by js...@apache.org on 2014/11/29 20:16:21 UTC

[09/10] drill git commit: DRILL-1749: Support nested maps in the flatten operator.

DRILL-1749: Support nested maps in the flatten operator.


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

Branch: refs/heads/master
Commit: 71ad125b410f62b718c7416b02a012f5a6d51c4f
Parents: 32e9711
Author: Jason Altekruse <al...@gmail.com>
Authored: Wed Nov 19 09:43:04 2014 -0800
Committer: Jason Altekruse <al...@gmail.com>
Committed: Fri Nov 28 22:28:25 2014 -0800

----------------------------------------------------------------------
 .../impl/flatten/FlattenRecordBatch.java        |  4 +-
 .../drill/exec/vector/complex/MapVector.java    |  5 ++-
 .../exec/physical/impl/flatten/TestFlatten.java |  5 ++-
 .../store/json/complex_repeated_map.json        | 45 ++++++++++++++++++++
 4 files changed, 56 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/71ad125b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/flatten/FlattenRecordBatch.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/flatten/FlattenRecordBatch.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/flatten/FlattenRecordBatch.java
index 78c1c50..9522e26 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/flatten/FlattenRecordBatch.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/flatten/FlattenRecordBatch.java
@@ -303,7 +303,9 @@ public class FlattenRecordBatch extends AbstractSingleRecordBatch<FlattenPOP> {
         incoming.getValueVectorId(popConfig.getColumn()).getFieldIds()).getValueVector();
 
     TransferPair tp = null;
-    if (flattenField instanceof RepeatedMapVector) {
+    if (flattenField instanceof MapVector) {
+      return null;
+    } else if (flattenField instanceof RepeatedMapVector) {
       tp = ((RepeatedMapVector)flattenField).getTransferPairToSingleMap();
     } else {
       ValueVector vvIn = ((RepeatedVector)flattenField).getAccessor().getAllChildValues();

http://git-wip-us.apache.org/repos/asf/drill/blob/71ad125b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/MapVector.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/MapVector.java b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/MapVector.java
index d8bd525..47b8252 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/MapVector.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/MapVector.java
@@ -281,7 +281,10 @@ public class MapVector extends AbstractContainerVector {
 
     @Override
     public void splitAndTransfer(int startIndex, int length) {
-      throw new UnsupportedOperationException();
+      for (TransferPair p : pairs) {
+        p.splitAndTransfer(startIndex, length);
+      }
+      to.getMutator().setValueCount(length);
     }
 
   }

http://git-wip-us.apache.org/repos/asf/drill/blob/71ad125b/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 960da65..23cf6cd 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
@@ -187,6 +187,9 @@ public class TestFlatten extends BaseTestQuery {
 
   }
 
-
+  @Test
+  public void testFlattenComplexRepeatedMap() throws Exception {
+    test("select a, flatten(r_map_1), flatten(r_map_2) from cp.`/store/json/complex_repeated_map.json`");
+  }
 
 }

http://git-wip-us.apache.org/repos/asf/drill/blob/71ad125b/exec/java-exec/src/test/resources/store/json/complex_repeated_map.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/store/json/complex_repeated_map.json b/exec/java-exec/src/test/resources/store/json/complex_repeated_map.json
new file mode 100644
index 0000000..20f02d8
--- /dev/null
+++ b/exec/java-exec/src/test/resources/store/json/complex_repeated_map.json
@@ -0,0 +1,45 @@
+{
+    "r_map_1" : [
+        { "a" : 1, "b" : 2, "c" : 3, "d" : { "sub_1" : 1, "sub_2" : 2} },
+        { "a" : 4, "b" : 5, "c" : 6, "d" : { "sub_1" : 10, "sub_2" : 9} }
+    ],
+    r_map_2 : [
+        { "a" : 21, "b" : 22, "c" : 23, "d" : [ 21,  22] },
+        { "a" : 24, "b" : 25, "c" : 26, "d" : [ 10,  9] }
+
+    ],
+    r_map_3 : [
+        { "a" : 1021, "b" : 1022, "c" : 1023, "d" : [ [1021, 1022], [1]] },
+        { "a" : 1024, "b" : 1025, "c" : 1026, "d" : [ [1010, 109], [2]] }
+    ]
+}
+{
+    "r_map_1" : [
+        { "a" : 101, "b" : 102, "c" : 103, "d" : { "sub_1" : 101, "sub_2" : 102} },
+        { "a" : 104, "b" : 105, "c" : 106, "d" : { "sub_1" : 1010, "sub_2" : 109} }
+    ],
+    r_map_2 : [
+        { "a" : 1021, "b" : 1022, "c" : 1023, "d" : [ 1021, 1022] },
+        { "a" : 1024, "b" : 1025, "c" : 1026, "d" : [ 1010, 109] }
+
+    ],
+    r_map_3 : [
+        { "a" : 1021, "b" : 1022, "c" : 1023, "d" : [ [1021, 1022], [1]] },
+        { "a" : 1024, "b" : 1025, "c" : 1026, "d" : [ [1010, 109], [2]] }
+    ]
+}
+{
+    "a" : 200,
+    "r_map_1" : [
+        { "a" : 101, "b" : 102, "c" : 103, "d" : { "sub_1" : 101, "sub_2" : 102} },
+        { "a" : 104, "b" : 105, "c" : 106, "d" : { "sub_1" : 1010, "sub_2" : 109} }
+    ],
+    r_map_2 : [
+        { "a" : 1021, "b" : 1022, "c" : 1023, "d" : [ 1021, 1022] },
+        { "a" : 1024, "b" : 1025, "c" : 1026, "d" : [ 1010, 109] }
+    ],
+    r_map_3 : [
+        { "a" : 1021, "b" : 1022, "c" : 1023, "d" : [ [1021, 1022], [1]] },
+        { "a" : 1024, "b" : 1025, "c" : 1026, "d" : [ [1010, 109], [2]] }
+    ]
+}