Search in sources :

Example 1 with LongVariableConstraint

use of io.trino.metadata.LongVariableConstraint in project trino by trinodb.

the class TestAnnotationEngineForAggregates method testLongConstraintAggregateFunctionParse.

@Test
public void testLongConstraintAggregateFunctionParse() {
    Signature expectedSignature = new Signature("parametric_aggregate_long_constraint", ImmutableList.of(), ImmutableList.of(new LongVariableConstraint("z", "x + y")), new TypeSignature("varchar", TypeSignatureParameter.typeVariable("z")), ImmutableList.of(new TypeSignature("varchar", TypeSignatureParameter.typeVariable("x")), new TypeSignature("varchar", TypeSignatureParameter.typeVariable("y"))), false);
    ParametricAggregation aggregation = getOnlyElement(parseFunctionDefinitions(LongConstraintAggregateFunction.class));
    assertEquals(aggregation.getFunctionMetadata().getDescription(), "Parametric aggregate with parametric type returned");
    assertTrue(aggregation.getFunctionMetadata().isDeterministic());
    assertEquals(aggregation.getFunctionMetadata().getSignature(), expectedSignature);
    ParametricImplementationsGroup<AggregationImplementation> implementations = aggregation.getImplementations();
    assertEquals(implementations.getGenericImplementations().size(), 1);
    AggregationImplementation implementation = implementations.getGenericImplementations().get(0);
    assertEquals(implementation.getDefinitionClass(), LongConstraintAggregateFunction.class);
    assertDependencyCount(implementation, 0, 0, 0);
    assertFalse(implementation.hasSpecializedTypeParameters());
    assertEquals(implementation.getInputParameterKinds(), ImmutableList.of(STATE, INPUT_CHANNEL, INPUT_CHANNEL));
    BoundSignature boundSignature = new BoundSignature(aggregation.getFunctionMetadata().getSignature().getName(), createVarcharType(30), ImmutableList.of(createVarcharType(17), createVarcharType(13)));
    AggregationFunctionMetadata aggregationMetadata = aggregation.getAggregationMetadata();
    assertFalse(aggregationMetadata.isOrderSensitive());
    assertFalse(aggregationMetadata.getIntermediateTypes().isEmpty());
    aggregation.specialize(boundSignature, NO_FUNCTION_DEPENDENCIES);
}
Also used : AggregationImplementation(io.trino.operator.aggregation.AggregationImplementation) TypeSignature(io.trino.spi.type.TypeSignature) LongVariableConstraint(io.trino.metadata.LongVariableConstraint) TypeSignature(io.trino.spi.type.TypeSignature) Signature(io.trino.metadata.Signature) BoundSignature(io.trino.metadata.BoundSignature) BoundSignature(io.trino.metadata.BoundSignature) ParametricAggregation(io.trino.operator.aggregation.ParametricAggregation) AggregationFunctionMetadata(io.trino.metadata.AggregationFunctionMetadata) Test(org.testng.annotations.Test)

Aggregations

AggregationFunctionMetadata (io.trino.metadata.AggregationFunctionMetadata)1 BoundSignature (io.trino.metadata.BoundSignature)1 LongVariableConstraint (io.trino.metadata.LongVariableConstraint)1 Signature (io.trino.metadata.Signature)1 AggregationImplementation (io.trino.operator.aggregation.AggregationImplementation)1 ParametricAggregation (io.trino.operator.aggregation.ParametricAggregation)1 TypeSignature (io.trino.spi.type.TypeSignature)1 Test (org.testng.annotations.Test)1