Search in sources :

Example 1 with OperatorImplementationDependency

use of io.trino.operator.annotations.OperatorImplementationDependency in project trino by trinodb.

the class TestAnnotationEngineForAggregates method testInjectOperatorAggregateParse.

@Test
public void testInjectOperatorAggregateParse() {
    Signature expectedSignature = new Signature("inject_operator_aggregate", DoubleType.DOUBLE.getTypeSignature(), ImmutableList.of(DoubleType.DOUBLE.getTypeSignature()));
    ParametricAggregation aggregation = getOnlyElement(parseFunctionDefinitions(InjectOperatorAggregateFunction.class));
    assertEquals(aggregation.getFunctionMetadata().getDescription(), "Simple aggregate with operator injected");
    assertTrue(aggregation.getFunctionMetadata().isDeterministic());
    assertEquals(aggregation.getFunctionMetadata().getSignature(), expectedSignature);
    ParametricImplementationsGroup<AggregationImplementation> implementations = aggregation.getImplementations();
    AggregationImplementation implementation = getOnlyElement(implementations.getExactImplementations().values());
    assertEquals(implementation.getDefinitionClass(), InjectOperatorAggregateFunction.class);
    assertDependencyCount(implementation, 1, 1, 1);
    assertTrue(implementation.getInputDependencies().get(0) instanceof OperatorImplementationDependency);
    assertTrue(implementation.getCombineDependencies().get(0) instanceof OperatorImplementationDependency);
    assertTrue(implementation.getOutputDependencies().get(0) instanceof OperatorImplementationDependency);
    assertFalse(implementation.hasSpecializedTypeParameters());
    assertEquals(implementation.getInputParameterKinds(), ImmutableList.of(STATE, INPUT_CHANNEL));
    BoundSignature boundSignature = new BoundSignature(aggregation.getFunctionMetadata().getSignature().getName(), DoubleType.DOUBLE, ImmutableList.of(DoubleType.DOUBLE));
    specializeAggregationFunction(boundSignature, aggregation);
}
Also used : AggregationImplementation(io.trino.operator.aggregation.AggregationImplementation) 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) OperatorImplementationDependency(io.trino.operator.annotations.OperatorImplementationDependency) Test(org.testng.annotations.Test)

Aggregations

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