use of com.amazonaws.athena.connector.lambda.data.SchemaSerDe in project aws-athena-query-federation by awslabs.
the class SchemaSerializationTest method serializationTest.
@Test
public void serializationTest() throws IOException {
logger.info("serializationTest - enter");
SchemaBuilder schemaBuilder = new SchemaBuilder();
schemaBuilder.addMetadata("meta1", "meta-value-1");
schemaBuilder.addMetadata("meta2", "meta-value-2");
schemaBuilder.addField("intfield1", new ArrowType.Int(32, true));
schemaBuilder.addField("doublefield2", new ArrowType.FloatingPoint(FloatingPointPrecision.DOUBLE));
schemaBuilder.addField("varcharfield3", new ArrowType.Utf8());
Schema expectedSchema = schemaBuilder.build();
SchemaSerDe serDe = new SchemaSerDe();
ByteArrayOutputStream schemaOut = new ByteArrayOutputStream();
serDe.serialize(expectedSchema, schemaOut);
TestPojo expected = new TestPojo(expectedSchema);
ByteArrayOutputStream out = new ByteArrayOutputStream();
objectMapper.writeValue(out, expected);
TestPojo actual = objectMapper.readValue(new ByteArrayInputStream(out.toByteArray()), TestPojo.class);
Schema actualSchema = actual.getSchema();
logger.info("serializationTest - fields[{}]", actualSchema.getFields());
logger.info("serializationTest - meta[{}]", actualSchema.getCustomMetadata());
assertEquals(expectedSchema.getFields(), actualSchema.getFields());
assertEquals(expectedSchema.getCustomMetadata(), actualSchema.getCustomMetadata());
logger.info("serializationTest - exit");
}
Aggregations