Search in sources :

Example 1 with OperatorImplementationDependency

use of com.facebook.presto.operator.annotations.OperatorImplementationDependency in project presto by prestodb.

the class TestAnnotationEngineForAggregates method testInjectOperatorAggregateParse.

@Test
public void testInjectOperatorAggregateParse() {
    Signature expectedSignature = new Signature(QualifiedObjectName.valueOf(DEFAULT_NAMESPACE, "inject_operator_aggregate"), FunctionKind.AGGREGATE, DoubleType.DOUBLE.getTypeSignature(), ImmutableList.of(DoubleType.DOUBLE.getTypeSignature()));
    ParametricAggregation aggregation = parseFunctionDefinition(InjectOperatorAggregateFunction.class);
    assertEquals(aggregation.getDescription(), "Simple aggregate with operator injected");
    assertTrue(aggregation.isDeterministic());
    assertEquals(aggregation.getSignature(), expectedSignature);
    ParametricImplementationsGroup<AggregationImplementation> implementations = aggregation.getImplementations();
    AggregationImplementation implementation = getOnlyElement(implementations.getExactImplementations().values());
    assertTrue(implementation.getStateSerializerFactory().isPresent());
    assertEquals(implementation.getDefinitionClass(), InjectOperatorAggregateFunction.class);
    assertDependencyCount(implementation, 1, 1, 1);
    assertEquals(implementation.getStateSerializerFactoryDependencies().size(), 1);
    assertTrue(implementation.getInputDependencies().get(0) instanceof OperatorImplementationDependency);
    assertTrue(implementation.getCombineDependencies().get(0) instanceof OperatorImplementationDependency);
    assertTrue(implementation.getOutputDependencies().get(0) instanceof OperatorImplementationDependency);
    assertTrue(implementation.getStateSerializerFactoryDependencies().get(0) instanceof OperatorImplementationDependency);
    assertFalse(implementation.hasSpecializedTypeParameters());
    List<AggregationMetadata.ParameterMetadata.ParameterType> expectedMetadataTypes = ImmutableList.of(AggregationMetadata.ParameterMetadata.ParameterType.STATE, AggregationMetadata.ParameterMetadata.ParameterType.INPUT_CHANNEL);
    assertTrue(implementation.getInputParameterMetadataTypes().equals(expectedMetadataTypes));
    InternalAggregationFunction specialized = aggregation.specialize(BoundVariables.builder().build(), 1, FUNCTION_AND_TYPE_MANAGER);
    assertEquals(specialized.getFinalType(), DoubleType.DOUBLE);
    assertTrue(specialized.isDecomposable());
    assertEquals(specialized.name(), "inject_operator_aggregate");
}
Also used : AggregationImplementation(com.facebook.presto.operator.aggregation.AggregationImplementation) TypeSignature(com.facebook.presto.common.type.TypeSignature) TypeSignature.parseTypeSignature(com.facebook.presto.common.type.TypeSignature.parseTypeSignature) Signature(com.facebook.presto.spi.function.Signature) AggregationMetadata(com.facebook.presto.operator.aggregation.AggregationMetadata) ParametricAggregation(com.facebook.presto.operator.aggregation.ParametricAggregation) OperatorImplementationDependency(com.facebook.presto.operator.annotations.OperatorImplementationDependency) InternalAggregationFunction(com.facebook.presto.operator.aggregation.InternalAggregationFunction) Test(org.testng.annotations.Test)

Aggregations

TypeSignature (com.facebook.presto.common.type.TypeSignature)1 TypeSignature.parseTypeSignature (com.facebook.presto.common.type.TypeSignature.parseTypeSignature)1 AggregationImplementation (com.facebook.presto.operator.aggregation.AggregationImplementation)1 AggregationMetadata (com.facebook.presto.operator.aggregation.AggregationMetadata)1 InternalAggregationFunction (com.facebook.presto.operator.aggregation.InternalAggregationFunction)1 ParametricAggregation (com.facebook.presto.operator.aggregation.ParametricAggregation)1 OperatorImplementationDependency (com.facebook.presto.operator.annotations.OperatorImplementationDependency)1 Signature (com.facebook.presto.spi.function.Signature)1 Test (org.testng.annotations.Test)1