use of org.apache.parquet.example.data.simple.SimpleGroupFactory in project parquet-mr by apache.
the class ValidatingColumnWriteStore method testReadUsingRequestedSchemaWithIncompatibleField.
@Test
public void testReadUsingRequestedSchemaWithIncompatibleField() {
MessageType originalSchema = new MessageType("schema", new PrimitiveType(OPTIONAL, INT32, "e"));
MemPageStore store = new MemPageStore(1);
SimpleGroupFactory groupFactory = new SimpleGroupFactory(originalSchema);
writeGroups(originalSchema, store, groupFactory.newGroup().append("e", 4));
try {
MessageType schemaWithIncompatibleField = new MessageType("schema", // Incompatible schema: different type
new PrimitiveType(OPTIONAL, BINARY, "e"));
readGroups(store, originalSchema, schemaWithIncompatibleField, 1);
fail("should have thrown an incompatible schema exception");
} catch (ParquetDecodingException e) {
assertEquals("The requested schema is not compatible with the file schema. incompatible types: optional binary e != optional int32 e", e.getMessage());
}
}
use of org.apache.parquet.example.data.simple.SimpleGroupFactory in project parquet-mr by apache.
the class ValidatingColumnWriteStore method testReadUsingSchemaWithRequiredFieldThatWasOptional.
@Test
public void testReadUsingSchemaWithRequiredFieldThatWasOptional() {
MessageType originalSchema = new MessageType("schema", new PrimitiveType(OPTIONAL, INT32, "e"));
MemPageStore store = new MemPageStore(1);
SimpleGroupFactory groupFactory = new SimpleGroupFactory(originalSchema);
writeGroups(originalSchema, store, groupFactory.newGroup().append("e", 4));
try {
MessageType schemaWithRequiredFieldThatWasOptional = new MessageType("schema", // Incompatible schema: required when it was optional
new PrimitiveType(REQUIRED, INT32, "e"));
readGroups(store, originalSchema, schemaWithRequiredFieldThatWasOptional, 1);
fail("should have thrown an incompatible schema exception");
} catch (ParquetDecodingException e) {
assertEquals("The requested schema is not compatible with the file schema. incompatible types: required int32 e != optional int32 e", e.getMessage());
}
}
Aggregations