Search in sources :

Example 1 with OperatorImplementationDependency

use of io.prestosql.operator.annotations.OperatorImplementationDependency in project hetu-core by openlookeng.

the class TestAnnotationEngineForAggregates method testInjectOperatorAggregateParse.

@Test
public void testInjectOperatorAggregateParse() {
    Signature expectedSignature = new Signature(QualifiedObjectName.valueOfDefaultFunction("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, METADATA.getFunctionAndTypeManager());
    assertEquals(specialized.getFinalType(), DoubleType.DOUBLE);
    assertTrue(specialized.isDecomposable());
    assertEquals(specialized.name(), "inject_operator_aggregate");
}
Also used : AggregationImplementation(io.prestosql.operator.aggregation.AggregationImplementation) TypeSignature.parseTypeSignature(io.prestosql.spi.type.TypeSignature.parseTypeSignature) TypeSignature(io.prestosql.spi.type.TypeSignature) Signature(io.prestosql.spi.function.Signature) AggregationMetadata(io.prestosql.operator.aggregation.AggregationMetadata) ParametricAggregation(io.prestosql.operator.aggregation.ParametricAggregation) OperatorImplementationDependency(io.prestosql.operator.annotations.OperatorImplementationDependency) InternalAggregationFunction(io.prestosql.operator.aggregation.InternalAggregationFunction) Test(org.testng.annotations.Test)

Aggregations

AggregationImplementation (io.prestosql.operator.aggregation.AggregationImplementation)1 AggregationMetadata (io.prestosql.operator.aggregation.AggregationMetadata)1 InternalAggregationFunction (io.prestosql.operator.aggregation.InternalAggregationFunction)1 ParametricAggregation (io.prestosql.operator.aggregation.ParametricAggregation)1 OperatorImplementationDependency (io.prestosql.operator.annotations.OperatorImplementationDependency)1 Signature (io.prestosql.spi.function.Signature)1 TypeSignature (io.prestosql.spi.type.TypeSignature)1 TypeSignature.parseTypeSignature (io.prestosql.spi.type.TypeSignature.parseTypeSignature)1 Test (org.testng.annotations.Test)1