drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h.@apache.org
Subject drill git commit: DRILL-2292: CTAS broken when we have repeated maps
Date Tue, 28 Apr 2015 22:39:02 GMT
Repository: drill
Updated Branches:
  refs/heads/master 5f1d6d7bb -> 5fbd274e0


DRILL-2292: CTAS broken when we have repeated maps


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

Branch: refs/heads/master
Commit: 5fbd274e0f397f4745f7f3f73c4e341052d35e37
Parents: 5f1d6d7
Author: adeneche <adeneche@gmail.com>
Authored: Tue Apr 14 18:40:39 2015 -0700
Committer: Hanifi Gunes <hgunes@maprtech.com>
Committed: Tue Apr 28 13:52:10 2015 -0700

----------------------------------------------------------------------
 .../complex/impl/RepeatedListReaderImpl.java    |  13 ++-
 .../complex/impl/RepeatedMapReaderImpl.java     |   5 +
 .../apache/drill/exec/TestRepeatedReaders.java  | 110 +++++++++++++++++++
 .../src/test/resources/parquet/2292.rl_rl.json  |  21 ++++
 .../src/test/resources/parquet/2292.rl_rm.json  |  21 ++++
 .../test/resources/parquet/2292.rm_m_rm.json    |  23 ++++
 .../src/test/resources/parquet/2292.rm_rl.json  |  23 ++++
 .../src/test/resources/parquet/2292.rm_rm.json  |  21 ++++
 8 files changed, 234 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/5fbd274e/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/impl/RepeatedListReaderImpl.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/impl/RepeatedListReaderImpl.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/impl/RepeatedListReaderImpl.java
index 767c366..36e9bee 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/impl/RepeatedListReaderImpl.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/impl/RepeatedListReaderImpl.java
@@ -23,6 +23,7 @@ import org.apache.drill.common.types.TypeProtos.MajorType;
 import org.apache.drill.common.types.TypeProtos.MinorType;
 import org.apache.drill.common.types.Types;
 import org.apache.drill.exec.expr.holders.RepeatedListHolder;
+import org.apache.drill.exec.vector.ValueVector;
 import org.apache.drill.exec.vector.complex.RepeatedListVector;
 import org.apache.drill.exec.vector.complex.reader.FieldReader;
 import org.apache.drill.exec.vector.complex.writer.BaseWriter.ListWriter;
@@ -85,6 +86,11 @@ public class RepeatedListReaderImpl extends AbstractFieldReader{
 
   @Override
   public void setPosition(int index) {
+    if (index < 0 || index == NO_VALUES) {
+      currentOffset = NO_VALUES;
+      return;
+    }
+
     super.setPosition(index);
     RepeatedListHolder h = new RepeatedListHolder();
     container.getAccessor().get(index, h);
@@ -121,12 +127,13 @@ public class RepeatedListReaderImpl extends AbstractFieldReader{
   @Override
   public FieldReader reader() {
     if (reader == null) {
-      reader = container.getChild(name).getReader();
-      if (currentOffset == NO_VALUES) {
+      ValueVector child = container.getChild(name);
+      if (child == null) {
         reader = NullReader.INSTANCE;
       } else {
-        reader.setPosition(currentOffset);
+        reader = child.getReader();
       }
+      reader.setPosition(currentOffset);
     }
     return reader;
   }

http://git-wip-us.apache.org/repos/asf/drill/blob/5fbd274e/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/impl/RepeatedMapReaderImpl.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/impl/RepeatedMapReaderImpl.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/impl/RepeatedMapReaderImpl.java
index 71a5017..b2fe7b7 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/impl/RepeatedMapReaderImpl.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/impl/RepeatedMapReaderImpl.java
@@ -96,6 +96,11 @@ public class RepeatedMapReaderImpl extends AbstractFieldReader{
 
   @Override
   public void setPosition(int index) {
+    if (index < 0 || index == NO_VALUES) {
+      currentOffset = NO_VALUES;
+      return;
+    }
+
     super.setPosition(index);
     RepeatedMapHolder h = new RepeatedMapHolder();
     vector.getAccessor().get(index, h);

http://git-wip-us.apache.org/repos/asf/drill/blob/5fbd274e/exec/java-exec/src/test/java/org/apache/drill/exec/TestRepeatedReaders.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/TestRepeatedReaders.java b/exec/java-exec/src/test/java/org/apache/drill/exec/TestRepeatedReaders.java
new file mode 100644
index 0000000..ddb67bb
--- /dev/null
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/TestRepeatedReaders.java
@@ -0,0 +1,110 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.drill.exec;
+
+import org.apache.drill.BaseTestQuery;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class TestRepeatedReaders extends BaseTestQuery {
+
+  static FileSystem fs;
+
+  @BeforeClass
+  public static void initFs() throws Exception {
+    Configuration conf = new Configuration();
+    conf.set(FileSystem.FS_DEFAULT_NAME_KEY, "local");
+
+    fs = FileSystem.get(conf);
+  }
+
+  private static void deleteTableIfExists(String tableName) {
+    try {
+      Path path = new Path(getDfsTestTmpSchemaLocation(), tableName);
+      if (fs.exists(path)) {
+        fs.delete(path, true);
+      }
+    } catch (Exception e) {
+      // ignore exceptions.
+    }
+  }
+
+  private void createAndQuery(String datafile) throws Exception {
+    String query = String.format("select * from cp.`parquet/%s`", datafile);
+    String tableName = "test_repeated_readers_"+datafile;
+
+    try {
+      test("create table dfs_test.tmp.`%s` as %s", tableName, query);
+
+      testBuilder()
+        .sqlQuery("select * from dfs_test.tmp.`%s` d", tableName)
+        .ordered()
+        .jsonBaselineFile("parquet/" + datafile)
+        .go();
+    } finally {
+      deleteTableIfExists(tableName);
+    }
+  }
+
+  @Test //DRILL-2292
+  public void testNestedRepeatedMapInsideRepeatedMap() throws Exception {
+    createAndQuery("2292.rm_rm.json");
+  }
+
+  @Test //DRILL-2292
+  public void testNestedRepeatedMapInsideMapInsideRepeatedMap() throws Exception {
+    createAndQuery("2292.rm_m_rm.json");
+  }
+
+  @Test //DRILL-2292
+  public void testNestedRepeatedListInsideRepeatedMap() throws Exception {
+    runSQL("alter session set `store.format` = 'json'");
+
+    try {
+      createAndQuery("2292.rl_rm.json");
+    } finally {
+      runSQL("alter session set `store.format` = 'parquet'");
+    }
+  }
+
+  @Test //DRILL-2292
+  public void testNestedRepeatedMapInsideRepeatedList() throws Exception {
+    runSQL("alter session set `store.format` = 'json'");
+
+    try {
+      createAndQuery("2292.rm_rl.json");
+    } finally {
+      runSQL("alter session set `store.format` = 'parquet'");
+    }
+  }
+
+  @Test //DRILL-2292
+  public void testNestedRepeatedListInsideRepeatedList() throws Exception {
+    runSQL("alter session set `store.format` = 'json'");
+
+    try {
+      createAndQuery("2292.rl_rl.json");
+    } finally {
+      runSQL("alter session set `store.format` = 'parquet'");
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/drill/blob/5fbd274e/exec/java-exec/src/test/resources/parquet/2292.rl_rl.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/parquet/2292.rl_rl.json b/exec/java-exec/src/test/resources/parquet/2292.rl_rl.json
new file mode 100644
index 0000000..5ce0a4c
--- /dev/null
+++ b/exec/java-exec/src/test/resources/parquet/2292.rl_rl.json
@@ -0,0 +1,21 @@
+{
+  "rp_list":[]
+}
+{
+  "rp_list":[]
+}
+{
+  "rp_list":[
+    [
+      [
+        ["a","b"]
+      ]
+    ]
+  ]
+}
+{
+  "rp_list":[]
+}
+{
+  "rp_list":[]
+}

http://git-wip-us.apache.org/repos/asf/drill/blob/5fbd274e/exec/java-exec/src/test/resources/parquet/2292.rl_rm.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/parquet/2292.rl_rm.json b/exec/java-exec/src/test/resources/parquet/2292.rl_rm.json
new file mode 100644
index 0000000..56b509c
--- /dev/null
+++ b/exec/java-exec/src/test/resources/parquet/2292.rl_rm.json
@@ -0,0 +1,21 @@
+{
+  "rp_map":[]
+}
+{
+"rp_map":[]
+}
+{
+  "rp_map":[
+    {
+      "rp_list": [
+        ["a","b"]
+      ]
+    }
+  ]
+}
+{
+"rp_map":[]
+}
+{
+"rp_map":[]
+}

http://git-wip-us.apache.org/repos/asf/drill/blob/5fbd274e/exec/java-exec/src/test/resources/parquet/2292.rm_m_rm.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/parquet/2292.rm_m_rm.json b/exec/java-exec/src/test/resources/parquet/2292.rm_m_rm.json
new file mode 100644
index 0000000..8c4487c
--- /dev/null
+++ b/exec/java-exec/src/test/resources/parquet/2292.rm_m_rm.json
@@ -0,0 +1,23 @@
+{
+  "rp_map":[]
+}
+{
+  "rp_map":[]
+}
+{
+  "rp_map":[
+    {
+      "map":{
+        "rp_map":[
+          {"b":"boo"}
+        ]
+      }
+    }
+  ]
+}
+{
+"rp_map":[]
+}
+{
+"rp_map":[]
+}

http://git-wip-us.apache.org/repos/asf/drill/blob/5fbd274e/exec/java-exec/src/test/resources/parquet/2292.rm_rl.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/parquet/2292.rm_rl.json b/exec/java-exec/src/test/resources/parquet/2292.rm_rl.json
new file mode 100644
index 0000000..80878a4
--- /dev/null
+++ b/exec/java-exec/src/test/resources/parquet/2292.rm_rl.json
@@ -0,0 +1,23 @@
+{
+  "rp_list":[]
+}
+{
+"rp_list":[]
+}
+{
+  "rp_list":[
+    [
+      {
+        "rp_map":[
+          {"b":"boo"}
+        ]
+      }
+    ]
+  ]
+}
+{
+"rp_list":[]
+}
+{
+"rp_list":[]
+}

http://git-wip-us.apache.org/repos/asf/drill/blob/5fbd274e/exec/java-exec/src/test/resources/parquet/2292.rm_rm.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/parquet/2292.rm_rm.json b/exec/java-exec/src/test/resources/parquet/2292.rm_rm.json
new file mode 100644
index 0000000..658ceab
--- /dev/null
+++ b/exec/java-exec/src/test/resources/parquet/2292.rm_rm.json
@@ -0,0 +1,21 @@
+{
+  "rp_map":[]
+}
+{
+"rp_map":[]
+}
+{
+  "rp_map":[
+    {
+      "rp_map":[
+        {"b":"boo"}
+      ]
+    }
+  ]
+}
+{
+"rp_map":[]
+}
+{
+"rp_map":[]
+}


Mime
View raw message