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 2020/09/22 21:20:56 UTC

[orc] branch branch-1.6 updated: ORC-667: Positional mapping for nested struct types should not applied by default

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

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


The following commit(s) were added to refs/heads/branch-1.6 by this push:
     new 8fd2c3a  ORC-667: Positional mapping for nested struct types should not applied by default
8fd2c3a is described below

commit 8fd2c3a7fe7dc361f122429c71c9f5a5964f4952
Author: Dongjoon Hyun <do...@apache.org>
AuthorDate: Sat Sep 19 21:20:53 2020 -0700

    ORC-667: Positional mapping for nested struct types should not applied by default
    
    Fixes #545
    
    Signed-off-by: Owen O'Malley <om...@apache.org>
---
 .../core/src/java/org/apache/orc/impl/SchemaEvolution.java |  2 +-
 .../src/test/org/apache/orc/impl/TestSchemaEvolution.java  | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

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 d7c6bd2..d2df1b9 100644
--- a/java/core/src/java/org/apache/orc/impl/SchemaEvolution.java
+++ b/java/core/src/java/org/apache/orc/impl/SchemaEvolution.java
@@ -513,7 +513,7 @@ public class SchemaEvolution {
             isOnlyImplicitConversion = false;
           }
 
-          if (positionalLevels == 0) {
+          if (positionalLevels <= 0) {
             List<String> readerFieldNames = readerType.getFieldNames();
             List<String> fileFieldNames = fileType.getFieldNames();
 
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 1cc653c..af30854 100644
--- a/java/core/src/test/org/apache/orc/impl/TestSchemaEvolution.java
+++ b/java/core/src/test/org/apache/orc/impl/TestSchemaEvolution.java
@@ -1733,6 +1733,20 @@ public class TestSchemaEvolution {
   }
 
   @Test
+  public void testStructInArrayWithoutPositionalEvolution() throws IOException {
+    options.forcePositionalEvolution(false);
+    options.positionalEvolutionLevel(Integer.MAX_VALUE);
+    TypeDescription file = TypeDescription.fromString("array<struct<x:string,y:int,z:double>>");
+    TypeDescription read = TypeDescription.fromString("array<struct<z:double,x:string,a:int,b:int>>");
+    SchemaEvolution evo = new SchemaEvolution(file, read, options);
+    assertEquals(1, evo.getFileType(1).getId());
+    assertEquals(4, evo.getFileType(2).getId());
+    assertEquals(2, evo.getFileType(3).getId());
+    assertNull(evo.getFileType(4));
+    assertNull(evo.getFileType(5));
+  }
+
+  @Test
   public void testPositionalEvolutionForStructInArray() throws IOException {
     options.forcePositionalEvolution(true);
     options.positionalEvolutionLevel(Integer.MAX_VALUE);