use of org.apache.parquet.schema.MessageTypeParser.parseMessageType in project parquet-mr by apache.
the class TestParquetParser method testIntAnnotations.
@Test
public void testIntAnnotations() {
String message = "message IntMessage {" + " required int32 i8 (INT_8);" + " required int32 i16 (INT_16);" + " required int32 i32 (INT_32);" + " required int64 i64 (INT_64);" + " required int32 u8 (UINT_8);" + " required int32 u16 (UINT_16);" + " required int32 u32 (UINT_32);" + " required int64 u64 (UINT_64);" + "}\n";
MessageType parsed = MessageTypeParser.parseMessageType(message);
MessageType expected = Types.buildMessage().required(INT32).as(INT_8).named("i8").required(INT32).as(INT_16).named("i16").required(INT32).as(INT_32).named("i32").required(INT64).as(INT_64).named("i64").required(INT32).as(UINT_8).named("u8").required(INT32).as(UINT_16).named("u16").required(INT32).as(UINT_32).named("u32").required(INT64).as(UINT_64).named("u64").named("IntMessage");
assertEquals(expected, parsed);
MessageType reparsed = MessageTypeParser.parseMessageType(parsed.toString());
assertEquals(expected, reparsed);
}
use of org.apache.parquet.schema.MessageTypeParser.parseMessageType in project parquet-mr by apache.
the class TestThriftSchemaConverter method testToMessageType.
@Test
public void testToMessageType() throws Exception {
String expected = "message ParquetSchema {\n" + " optional group persons (LIST) = 1 {\n" + " repeated group persons_tuple {\n" + " required group name = 1 {\n" + " optional binary first_name (UTF8) = 1;\n" + " optional binary last_name (UTF8) = 2;\n" + " }\n" + " optional int32 id = 2;\n" + " optional binary email (UTF8) = 3;\n" + " optional group phones (LIST) = 4 {\n" + " repeated group phones_tuple {\n" + " optional binary number (UTF8) = 1;\n" + " optional binary type (ENUM) = 2;\n" + " }\n" + " }\n" + " }\n" + " }\n" + "}";
ThriftSchemaConverter schemaConverter = new ThriftSchemaConverter();
final MessageType converted = schemaConverter.convert(AddressBook.class);
assertEquals(MessageTypeParser.parseMessageType(expected), converted);
}
use of org.apache.parquet.schema.MessageTypeParser.parseMessageType in project parquet-mr by apache.
the class TestParquetParser method testEmbeddedAnnotations.
@Test
public void testEmbeddedAnnotations() {
String message = "message EmbeddedMessage {" + " required binary json (JSON);" + " required binary bson (BSON);" + "}\n";
MessageType parsed = MessageTypeParser.parseMessageType(message);
MessageType expected = Types.buildMessage().required(BINARY).as(JSON).named("json").required(BINARY).as(BSON).named("bson").named("EmbeddedMessage");
assertEquals(expected, parsed);
MessageType reparsed = MessageTypeParser.parseMessageType(parsed.toString());
assertEquals(expected, reparsed);
}
use of org.apache.parquet.schema.MessageTypeParser.parseMessageType in project parquet-mr by apache.
the class TestParquetParser method testTimeAnnotations.
@Test
public void testTimeAnnotations() {
String message = "message TimeMessage {" + " required int32 date (DATE);" + " required int32 time (TIME_MILLIS);" + " required int64 timestamp (TIMESTAMP_MILLIS);" + " required FIXED_LEN_BYTE_ARRAY(12) interval (INTERVAL);" + "}\n";
MessageType parsed = MessageTypeParser.parseMessageType(message);
MessageType expected = Types.buildMessage().required(INT32).as(DATE).named("date").required(INT32).as(TIME_MILLIS).named("time").required(INT64).as(TIMESTAMP_MILLIS).named("timestamp").required(FIXED_LEN_BYTE_ARRAY).length(12).as(INTERVAL).named("interval").named("TimeMessage");
assertEquals(expected, parsed);
MessageType reparsed = MessageTypeParser.parseMessageType(parsed.toString());
assertEquals(expected, reparsed);
}
Aggregations