Search in sources :

Example 6 with TestingColumnHandle

use of com.facebook.presto.testing.TestingMetadata.TestingColumnHandle in project presto by prestodb.

the class TestLocalProperties method testJsonSerialization.

@Test
public void testJsonSerialization() throws Exception {
    ObjectMapper mapper = new JsonObjectMapperProvider().get().registerModule(new SimpleModule().addDeserializer(ColumnHandle.class, new JsonDeserializer<ColumnHandle>() {

        @Override
        public ColumnHandle deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
            return new JsonObjectMapperProvider().get().readValue(jsonParser, TestingColumnHandle.class);
        }
    }));
    TestingColumnHandle columnHandle = new TestingColumnHandle("a");
    LocalProperty<ColumnHandle> property1 = new ConstantProperty<>(columnHandle);
    assertEquals(property1, mapper.readValue(mapper.writeValueAsString(property1), new TypeReference<LocalProperty<ColumnHandle>>() {
    }));
    LocalProperty<ColumnHandle> property2 = new SortingProperty<>(columnHandle, SortOrder.ASC_NULLS_FIRST);
    assertEquals(property2, mapper.readValue(mapper.writeValueAsString(property2), new TypeReference<LocalProperty<ColumnHandle>>() {
    }));
    LocalProperty<ColumnHandle> property3 = new GroupingProperty<>(ImmutableList.of(columnHandle));
    assertEquals(property3, mapper.readValue(mapper.writeValueAsString(property3), new TypeReference<LocalProperty<ColumnHandle>>() {
    }));
}
Also used : TestingColumnHandle(com.facebook.presto.testing.TestingMetadata.TestingColumnHandle) ColumnHandle(com.facebook.presto.spi.ColumnHandle) ConstantProperty(com.facebook.presto.spi.ConstantProperty) GroupingProperty(com.facebook.presto.spi.GroupingProperty) SortingProperty(com.facebook.presto.spi.SortingProperty) JsonDeserializer(com.fasterxml.jackson.databind.JsonDeserializer) TestingColumnHandle(com.facebook.presto.testing.TestingMetadata.TestingColumnHandle) JsonObjectMapperProvider(com.facebook.airlift.json.JsonObjectMapperProvider) DeserializationContext(com.fasterxml.jackson.databind.DeserializationContext) TypeReference(com.fasterxml.jackson.core.type.TypeReference) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) JsonParser(com.fasterxml.jackson.core.JsonParser) Test(org.testng.annotations.Test)

Aggregations

TestingColumnHandle (com.facebook.presto.testing.TestingMetadata.TestingColumnHandle)6 TableScanNode (com.facebook.presto.spi.plan.TableScanNode)5 VariableReferenceExpression (com.facebook.presto.spi.relation.VariableReferenceExpression)5 TableHandle (com.facebook.presto.spi.TableHandle)4 PlanNodeId (com.facebook.presto.spi.plan.PlanNodeId)4 TestingTableHandle (com.facebook.presto.testing.TestingMetadata.TestingTableHandle)4 ConnectorId (com.facebook.presto.spi.ConnectorId)3 ColumnHandle (com.facebook.presto.spi.ColumnHandle)2 PlanNode (com.facebook.presto.spi.plan.PlanNode)2 PartitioningScheme (com.facebook.presto.sql.planner.PartitioningScheme)2 PlanFragment (com.facebook.presto.sql.planner.PlanFragment)2 JoinNode (com.facebook.presto.sql.planner.plan.JoinNode)2 PlanFragmentId (com.facebook.presto.sql.planner.plan.PlanFragmentId)2 RemoteSourceNode (com.facebook.presto.sql.planner.plan.RemoteSourceNode)2 JsonObjectMapperProvider (com.facebook.airlift.json.JsonObjectMapperProvider)1 TableWriteInfo (com.facebook.presto.execution.scheduler.TableWriteInfo)1 Split (com.facebook.presto.metadata.Split)1 ConstantProperty (com.facebook.presto.spi.ConstantProperty)1 GroupingProperty (com.facebook.presto.spi.GroupingProperty)1 SortingProperty (com.facebook.presto.spi.SortingProperty)1