Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1944,14 +1944,9 @@ private static TypeReader createStringConvertTreeReader(int columnId,
return new DecimalFromStringGroupTreeReader(columnId, fileType, readerType, context);

case CHAR:
return new StringGroupFromStringGroupTreeReader(columnId, fileType, readerType, context);

case VARCHAR:
return new StringGroupFromStringGroupTreeReader(columnId, fileType, readerType, context);

case STRING:
throw new IllegalArgumentException("No conversion of type " +
readerType.getCategory() + " to self needed");
return new StringGroupFromStringGroupTreeReader(columnId, fileType, readerType, context);

case BINARY:
return new BinaryTreeReader(columnId, context);
Expand Down
32 changes: 32 additions & 0 deletions java/core/src/test/org/apache/orc/impl/TestSchemaEvolution.java
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,38 @@ public void testDecimalToDecimal64Evolution() throws Exception {
rows.close();
}

@Test
public void testCharToStringEvolution() throws IOException {
TypeDescription fileType = TypeDescription.fromString("struct<x:char(10)>");
TypeDescription readType = TypeDescription.fromString("struct<x:string>");
SchemaEvolution evo = new SchemaEvolution(fileType, readType, options);

TreeReaderFactory.Context treeContext =
new TreeReaderFactory.ReaderContext().setSchemaEvolution(evo);
TypeReader reader =
TreeReaderFactory.createTreeReader(readType, treeContext);

// Make sure the tree reader is built properly
assertEquals(TreeReaderFactory.StructTreeReader.class, reader.getClass());
TypeReader[] children =
((TreeReaderFactory.StructTreeReader) reader).getChildReaders();
assertEquals(1, children.length);
assertEquals(ConvertTreeReaderFactory.StringGroupFromStringGroupTreeReader.class, children[0].getClass());

// Make sure that varchar behaves the same as char
fileType = TypeDescription.fromString("struct<x:varchar(10)>");
evo = new SchemaEvolution(fileType, readType, options);

treeContext = new TreeReaderFactory.ReaderContext().setSchemaEvolution(evo);
reader = TreeReaderFactory.createTreeReader(readType, treeContext);

// Make sure the tree reader is built properly
assertEquals(TreeReaderFactory.StructTreeReader.class, reader.getClass());
children = ((TreeReaderFactory.StructTreeReader) reader).getChildReaders();
assertEquals(1, children.length);
assertEquals(ConvertTreeReaderFactory.StringGroupFromStringGroupTreeReader.class, children[0].getClass());
}

@Test
public void testStringToDecimalEvolution() throws Exception {
testFilePath = new Path(workDir, "TestSchemaEvolution." +
Expand Down