You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@orc.apache.org by pr...@apache.org on 2019/04/12 23:55:41 UTC

[orc] branch branch-1.5 updated: ORC-491: PPD Column name lookups need to look a struct deeper for ACID (#381) (#383)

This is an automated email from the ASF dual-hosted git repository.

prasanthj pushed a commit to branch branch-1.5
in repository https://gitbox.apache.org/repos/asf/orc.git


The following commit(s) were added to refs/heads/branch-1.5 by this push:
     new 466c1bb  ORC-491: PPD Column name lookups need to look a struct deeper for ACID (#381) (#383)
466c1bb is described below

commit 466c1bb736815bb928be43aa12c5fb10efd08fb8
Author: Vineet G <vg...@apache.org>
AuthorDate: Fri Apr 12 16:55:36 2019 -0700

    ORC-491: PPD Column name lookups need to look a struct deeper for ACID (#381) (#383)
---
 .../src/java/org/apache/orc/TypeDescription.java   |  4 +++-
 .../test/org/apache/orc/TestTypeDescription.java   | 22 ++++++++++++++++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/java/core/src/java/org/apache/orc/TypeDescription.java b/java/core/src/java/org/apache/orc/TypeDescription.java
index a6affd1..8372207 100644
--- a/java/core/src/java/org/apache/orc/TypeDescription.java
+++ b/java/core/src/java/org/apache/orc/TypeDescription.java
@@ -30,6 +30,7 @@ import org.apache.hadoop.hive.ql.exec.vector.StructColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.TimestampColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.UnionColumnVector;
 import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.orc.impl.SchemaEvolution;
 
 import java.io.Serializable;
 import java.util.ArrayList;
@@ -987,7 +988,8 @@ public class TypeDescription
     if (names.size() == 1 && INTEGER_PATTERN.matcher(names.get(0)).matches()) {
       return findSubtype(Integer.parseInt(names.get(0)));
     }
-    TypeDescription current = this;
+    TypeDescription current = SchemaEvolution.checkAcidSchema(this)
+        ? SchemaEvolution.getBaseRow(this) : this;
     while (names.size() > 0) {
       String first = names.remove(0);
       switch (current.category) {
diff --git a/java/core/src/test/org/apache/orc/TestTypeDescription.java b/java/core/src/test/org/apache/orc/TestTypeDescription.java
index cb2e8d7..570c7f4 100644
--- a/java/core/src/test/org/apache/orc/TestTypeDescription.java
+++ b/java/core/src/test/org/apache/orc/TestTypeDescription.java
@@ -303,4 +303,26 @@ public class TestTypeDescription {
     results = type.findSubtypes("");
     assertEquals(0, results.size());
   }
+
+  @Test
+  public void testFindSubtypesAcid() {
+    TypeDescription type = TypeDescription.fromString(
+        "struct<operation:int,originalTransaction:bigint,bucket:int," +
+            "rowId:bigint,currentTransaction:bigint," +
+            "row:struct<col0:int,col1:struct<z:int,x:double,y:string>," +
+            "col2:double>>");
+    List<TypeDescription> results = type.findSubtypes("col0");
+    assertEquals(1, results.size());
+    assertEquals(7, results.get(0).getId());
+
+    results = type.findSubtypes("col1,col2,col1.x,col1.z");
+    assertEquals(4, results.size());
+    assertEquals(8, results.get(0).getId());
+    assertEquals(12, results.get(1).getId());
+    assertEquals(10, results.get(2).getId());
+    assertEquals(9, results.get(3).getId());
+
+    results = type.findSubtypes("");
+    assertEquals(0, results.size());
+  }
 }