use of io.trino.type.TypeDeserializer in project trino by trinodb.
the class TestIcebergColumnHandle method testRoundTrip.
private void testRoundTrip(IcebergColumnHandle expected) {
ObjectMapperProvider objectMapperProvider = new ObjectMapperProvider();
objectMapperProvider.setJsonDeserializers(ImmutableMap.of(Type.class, new TypeDeserializer(TESTING_TYPE_MANAGER)));
JsonCodec<IcebergColumnHandle> codec = new JsonCodecFactory(objectMapperProvider).jsonCodec(IcebergColumnHandle.class);
String json = codec.toJson(expected);
IcebergColumnHandle actual = codec.fromJson(json);
assertEquals(actual, expected);
assertEquals(actual.getBaseColumnIdentity(), expected.getBaseColumnIdentity());
assertEquals(actual.getBaseType(), expected.getBaseType());
assertEquals(actual.getQualifiedName(), expected.getQualifiedName());
assertEquals(actual.getName(), expected.getName());
assertEquals(actual.getColumnIdentity(), expected.getColumnIdentity());
assertEquals(actual.getId(), actual.getId());
assertEquals(actual.getType(), expected.getType());
assertEquals(actual.getComment(), expected.getComment());
}
use of io.trino.type.TypeDeserializer in project trino by trinodb.
the class TestPatternRecognitionNodeSerialization method testAggregationValuePointerRoundtrip.
@Test
public void testAggregationValuePointerRoundtrip() {
ObjectMapperProvider provider = new ObjectMapperProvider();
provider.setJsonSerializers(ImmutableMap.of(Expression.class, new ExpressionSerialization.ExpressionSerializer()));
provider.setJsonDeserializers(ImmutableMap.of(Expression.class, new ExpressionSerialization.ExpressionDeserializer(new SqlParser()), Type.class, new TypeDeserializer(TESTING_TYPE_MANAGER)));
provider.setKeyDeserializers(ImmutableMap.of(TypeSignature.class, new TypeSignatureKeyDeserializer()));
JsonCodec<ValuePointer> codec = new JsonCodecFactory(provider).jsonCodec(ValuePointer.class);
ResolvedFunction countFunction = createTestMetadataManager().resolveFunction(TEST_SESSION, QualifiedName.of("count"), ImmutableList.of());
assertJsonRoundTrip(codec, new AggregationValuePointer(countFunction, new AggregatedSetDescriptor(ImmutableSet.of(), false), ImmutableList.of(), new Symbol("classifier"), new Symbol("match_number")));
ResolvedFunction maxFunction = createTestMetadataManager().resolveFunction(TEST_SESSION, QualifiedName.of("max"), fromTypes(BIGINT));
assertJsonRoundTrip(codec, new AggregationValuePointer(maxFunction, new AggregatedSetDescriptor(ImmutableSet.of(new IrLabel("A"), new IrLabel("B")), true), ImmutableList.of(new NullLiteral()), new Symbol("classifier"), new Symbol("match_number")));
}
Aggregations