use of org.apache.parquet.thrift.struct.ThriftType.EnumValue in project parquet-mr by apache.
the class TestThriftRecordConverter method testUnknownEnumThrowsGoodException.
@Test
public void testUnknownEnumThrowsGoodException() throws Exception {
EnumType et = new EnumType(Arrays.asList(new EnumValue(77, "hello")));
ThriftField field = new ThriftField("name", (short) 1, Requirement.REQUIRED, et);
ArrayList<TProtocol> events = new ArrayList<TProtocol>();
FieldEnumConverter conv = new FieldEnumConverter(events, field);
conv.addBinary(Binary.fromString("hello"));
assertEquals(1, events.size());
assertEquals(77, events.get(0).readI32());
try {
conv.addBinary(Binary.fromString("FAKE_ENUM_VALUE"));
fail("this should throw");
} catch (ParquetDecodingException e) {
assertEquals("Unrecognized enum value: FAKE_ENUM_VALUE known values: {Binary{\"hello\"}=77} in {\n" + " \"name\" : \"name\",\n" + " \"fieldId\" : 1,\n" + " \"requirement\" : \"REQUIRED\",\n" + " \"type\" : {\n" + " \"id\" : \"ENUM\",\n" + " \"values\" : [ {\n" + " \"id\" : 77,\n" + " \"name\" : \"hello\"\n" + " } ]\n" + " }\n" + "}", e.getMessage());
}
}
Aggregations