java/core/src/test/org/apache/orc/impl/TestSchemaEvolution.java
@Test
  public void testAddSimilarField() {
    TypeDescription fileType =
        TypeDescription.fromString("struct<a:struct<b:int>>");
    TypeDescription readerType =
        TypeDescription.fromString("struct<a:struct<b:int>,c:struct<b:int>>");
    boolean[] included = includeAll(readerType);
    options.tolerateMissingSchema(false);
    SchemaEvolution transition =
        new SchemaEvolution(fileType, readerType, options.include(included));

    // a -> a
    TypeDescription reader = readerType.getChildren().get(0);
    TypeDescription mapped = transition.getFileType(reader);
    TypeDescription original = fileType.getChildren().get(0);
    assertSame(original, mapped);

    // a.b -> a.b
    TypeDescription readerChild = reader.getChildren().get(0);
    mapped = transition.getFileType(readerChild);
    TypeDescription originalChild = original.getChildren().get(0);
    assertSame(originalChild, mapped);

    // c -> null
    reader = readerType.getChildren().get(1);
    mapped = transition.getFileType(reader);
    original = null;
    assertSame(original, mapped);

    // c.b -> null
    readerChild = reader.getChildren().get(0);
    mapped = transition.getFileType(readerChild);
    original = null;
    assertSame(original, mapped);
  }
/**
   * Two structs can be equal but in different locations. They can converge to this.
   */
Two structs can be equal but in different locations. They can converge to this.
Two structs can be equal but in different locations . They can converge to this .
@Test
  public void testAddSimilarField() {
    TypeDescription fileType =
        TypeDescription.fromString("struct<a:struct<b:int>>");
    TypeDescription readerType =
        TypeDescription.fromString("struct<a:struct<b:int>,c:struct<b:int>>");
    boolean[] included = includeAll(readerType);
    options.tolerateMissingSchema(false);
    SchemaEvolution transition =
        new SchemaEvolution(fileType, readerType, options.include(included));
    TypeDescription reader = readerType.getChildren().get(0);
    TypeDescription mapped = transition.getFileType(reader);
    TypeDescription original = fileType.getChildren().get(0);
    assertSame(original, mapped);
    TypeDescription readerChild = reader.getChildren().get(0);
    mapped = transition.getFileType(readerChild);
    TypeDescription originalChild = original.getChildren().get(0);
    assertSame(originalChild, mapped);
    reader = readerType.getChildren().get(1);
    mapped = transition.getFileType(reader);
    original = null;
    assertSame(original, mapped);
    readerChild = reader.getChildren().get(0);
    mapped = transition.getFileType(readerChild);
    original = null;
    assertSame(original, mapped);
  }
@ Test public void testAddSimilarField ( ) { TypeDescription fileType = TypeDescription . fromString ( "struct<a:struct<b:int>>" ) ; TypeDescription readerType = TypeDescription . fromString ( "struct<a:struct<b:int>,c:struct<b:int>>" ) ; boolean [ ] included = includeAll ( readerType ) ; options . tolerateMissingSchema ( false ) ; SchemaEvolution transition = new SchemaEvolution ( fileType , readerType , options . include ( included ) ) ; TypeDescription reader = readerType . getChildren ( ) . get ( 0 ) ; TypeDescription mapped = transition . getFileType ( reader ) ; TypeDescription original = fileType . getChildren ( ) . get ( 0 ) ; assertSame ( original , mapped ) ; TypeDescription readerChild = reader . getChildren ( ) . get ( 0 ) ; mapped = transition . getFileType ( readerChild ) ; TypeDescription originalChild = original . getChildren ( ) . get ( 0 ) ; assertSame ( originalChild , mapped ) ; reader = readerType . getChildren ( ) . get ( 1 ) ; mapped = transition . getFileType ( reader ) ; original = null ; assertSame ( original , mapped ) ; readerChild = reader . getChildren ( ) . get ( 0 ) ; mapped = transition . getFileType ( readerChild ) ; original = null ; assertSame ( original , mapped ) ; }
Two structs can be equal but in different locations.
Two structs can be equal but in different locations .
// a -> a // a.b -> a.b // c -> null // c.b -> null