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");
}
Aggregations