use of org.apache.parquet.thrift.test.StructWithExtraField in project parquet-mr by apache.
the class TestProtocolReadToWrite method TestExtraFieldWhenFieldIndexIsNotStartFromZero.
@Test
public void TestExtraFieldWhenFieldIndexIsNotStartFromZero() throws Exception {
CountingErrorHandler countingHandler = new CountingErrorHandler() {
@Override
public void handleFieldIgnored(TField field) {
assertEquals(3, field.id);
fieldIgnoredCount++;
}
};
BufferedProtocolReadToWrite structForRead = new BufferedProtocolReadToWrite(ThriftSchemaConverter.toStructType(StructWithIndexStartsFrom4.class), countingHandler);
// Data has an extra field of type struct
final ByteArrayOutputStream in = new ByteArrayOutputStream();
StructWithExtraField dataWithNewExtraField = new StructWithExtraField(new Phone("111", "222"), new Phone("333", "444"));
dataWithNewExtraField.write(protocol(in));
// read using the schema that doesn't have the extra field
final ByteArrayOutputStream out = new ByteArrayOutputStream();
structForRead.readOne(protocol(new ByteArrayInputStream(in.toByteArray())), protocol(out));
assertEquals(1, countingHandler.recordCountOfMissingFields);
assertEquals(1, countingHandler.fieldIgnoredCount);
}
Aggregations