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 20:02:57 UTC

[orc] branch master 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 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 8c63a0d  ORC-667: Positional mapping for nested struct types should not applied by default
8c63a0d is described below

commit 8c63a0d8c03659de54adbfbeccccc579cbc72516
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 3c41ffc..3d2b2cf 100644
--- a/java/core/src/test/org/apache/orc/impl/TestSchemaEvolution.java
+++ b/java/core/src/test/org/apache/orc/impl/TestSchemaEvolution.java
@@ -1737,6 +1737,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);