This is an automated email from the ASF dual-hosted git repository. prasanthj pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/orc.git
The following commit(s) were added to refs/heads/master by this push: new fd0b9f9 ORC-491: PPD Column name lookups need to look a struct deeper for ACID (#381) fd0b9f9 is described below commit fd0b9f9f1a25d37614e2ad79c273b74e7ee02617 Author: Vineet G <vg...@cloudera.com> AuthorDate: Thu Apr 11 13:50:00 2019 -0700 ORC-491: PPD Column name lookups need to look a struct deeper for ACID (#381) --- .../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()); + } }