You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@orc.apache.org by om...@apache.org on 2019/11/05 18:25:46 UTC

[orc] branch branch-1.5 updated: ORC-562:Don't wrap readerSchema in acidSchema, if readerSchema is already acid

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

omalley 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 39674f9  ORC-562:Don't wrap readerSchema in acidSchema, if readerSchema is already acid
39674f9 is described below

commit 39674f9e9f749215d69f44bf4f1a5e8ac18ba08e
Author: Laszlo Pinter <lp...@cloudera.com>
AuthorDate: Thu Oct 24 10:13:53 2019 +0200

    ORC-562:Don't wrap readerSchema in acidSchema, if readerSchema is already acid
    
    Fixes #442
    
    Signed-off-by: Owen O'Malley <om...@apache.org>
---
 .../java/org/apache/orc/impl/SchemaEvolution.java    |  5 +++--
 .../org/apache/orc/impl/TestSchemaEvolution.java     | 20 ++++++++++++++++++++
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/java/core/src/java/org/apache/orc/impl/SchemaEvolution.java b/java/core/src/java/org/apache/orc/impl/SchemaEvolution.java
index 1d4cc67..e570035 100644
--- a/java/core/src/java/org/apache/orc/impl/SchemaEvolution.java
+++ b/java/core/src/java/org/apache/orc/impl/SchemaEvolution.java
@@ -83,10 +83,11 @@ public class SchemaEvolution {
     this.isOnlyImplicitConversion = true;
     this.fileSchema = fileSchema;
     isAcid = checkAcidSchema(fileSchema);
+    boolean readerSchemaIsAcid = readerSchema == null ? false : checkAcidSchema(readerSchema);
     includeAcidColumns = options.getIncludeAcidColumns();
-    this.readerColumnOffset = isAcid ? acidEventFieldNames.size() : 0;
+    this.readerColumnOffset = isAcid && !readerSchemaIsAcid ? acidEventFieldNames.size() : 0;
     if (readerSchema != null) {
-      if (isAcid) {
+      if (isAcid && !readerSchemaIsAcid) {
         this.readerSchema = createEventSchema(readerSchema);
       } else {
         this.readerSchema = readerSchema;
diff --git a/java/core/src/test/org/apache/orc/impl/TestSchemaEvolution.java b/java/core/src/test/org/apache/orc/impl/TestSchemaEvolution.java
index 4edc1b4..0f0e93b 100644
--- a/java/core/src/test/org/apache/orc/impl/TestSchemaEvolution.java
+++ b/java/core/src/test/org/apache/orc/impl/TestSchemaEvolution.java
@@ -1650,4 +1650,24 @@ public class TestSchemaEvolution {
     assertEquals(3, evo.getFileType(3).getId());
     assertEquals(null, evo.getFileType(4));
   }
+
+  @Test
+  public void testAcidReaderSchema() {
+    String acidSchema = "struct<operation:int,originalTransaction:bigint,bucket:int," +
+        "rowId:bigint,currentTransaction:bigint," +
+        "row:struct<a:int,b:int>>";
+
+    TypeDescription fileSchema = TypeDescription.fromString(acidSchema);
+    TypeDescription readerSchema = TypeDescription.fromString(acidSchema);
+    SchemaEvolution schemaEvolution = new SchemaEvolution(fileSchema, readerSchema, options);
+
+    assertEquals(String.format("Reader schema %s is not acid", schemaEvolution.getReaderSchema().toString()),
+        acidSchema, schemaEvolution.getReaderSchema().toString());
+
+    String notAcidSchema ="struct<a:int,b:int>";
+    readerSchema = TypeDescription.fromString(notAcidSchema);
+    schemaEvolution = new SchemaEvolution(fileSchema, readerSchema, options);
+    assertEquals(String.format("Reader schema %s is not acid", schemaEvolution.getReaderSchema().toString()),
+        acidSchema, schemaEvolution.getReaderSchema().toString());
+  }
 }