Search in sources :

Example 1 with AggregatedSetDescriptor

use of io.trino.sql.planner.rowpattern.AggregatedSetDescriptor 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")));
}
Also used : IrLabel(io.trino.sql.planner.rowpattern.ir.IrLabel) ResolvedFunction(io.trino.metadata.ResolvedFunction) Symbol(io.trino.sql.planner.Symbol) SqlParser(io.trino.sql.parser.SqlParser) AggregationValuePointer(io.trino.sql.planner.rowpattern.AggregationValuePointer) ScalarValuePointer(io.trino.sql.planner.rowpattern.ScalarValuePointer) ValuePointer(io.trino.sql.planner.rowpattern.ValuePointer) ObjectMapperProvider(io.airlift.json.ObjectMapperProvider) AggregationValuePointer(io.trino.sql.planner.rowpattern.AggregationValuePointer) Type(io.trino.spi.type.Type) TypeSignature(io.trino.spi.type.TypeSignature) AggregatedSetDescriptor(io.trino.sql.planner.rowpattern.AggregatedSetDescriptor) ArithmeticUnaryExpression(io.trino.sql.tree.ArithmeticUnaryExpression) ComparisonExpression(io.trino.sql.tree.ComparisonExpression) IfExpression(io.trino.sql.tree.IfExpression) Expression(io.trino.sql.tree.Expression) TypeDeserializer(io.trino.type.TypeDeserializer) JsonCodecFactory(io.airlift.json.JsonCodecFactory) NullLiteral(io.trino.sql.tree.NullLiteral) TypeSignatureKeyDeserializer(io.trino.type.TypeSignatureKeyDeserializer) Test(org.testng.annotations.Test)

Aggregations

JsonCodecFactory (io.airlift.json.JsonCodecFactory)1 ObjectMapperProvider (io.airlift.json.ObjectMapperProvider)1 ResolvedFunction (io.trino.metadata.ResolvedFunction)1 Type (io.trino.spi.type.Type)1 TypeSignature (io.trino.spi.type.TypeSignature)1 SqlParser (io.trino.sql.parser.SqlParser)1 Symbol (io.trino.sql.planner.Symbol)1 AggregatedSetDescriptor (io.trino.sql.planner.rowpattern.AggregatedSetDescriptor)1 AggregationValuePointer (io.trino.sql.planner.rowpattern.AggregationValuePointer)1 ScalarValuePointer (io.trino.sql.planner.rowpattern.ScalarValuePointer)1 ValuePointer (io.trino.sql.planner.rowpattern.ValuePointer)1 IrLabel (io.trino.sql.planner.rowpattern.ir.IrLabel)1 ArithmeticUnaryExpression (io.trino.sql.tree.ArithmeticUnaryExpression)1 ComparisonExpression (io.trino.sql.tree.ComparisonExpression)1 Expression (io.trino.sql.tree.Expression)1 IfExpression (io.trino.sql.tree.IfExpression)1 NullLiteral (io.trino.sql.tree.NullLiteral)1 TypeDeserializer (io.trino.type.TypeDeserializer)1 TypeSignatureKeyDeserializer (io.trino.type.TypeSignatureKeyDeserializer)1 Test (org.testng.annotations.Test)1