use of io.prestosql.operator.annotations.ImplementationDependency in project hetu-core by openlookeng.
the class TestAnnotationEngineForScalars method testConstructorInjectionScalarParse.
@Test
public void testConstructorInjectionScalarParse() {
Signature expectedSignature = new Signature(QualifiedObjectName.valueOfDefaultFunction("parametric_scalar_inject_constructor"), FunctionKind.SCALAR, ImmutableList.of(typeVariable("T")), ImmutableList.of(), BIGINT.getTypeSignature(), ImmutableList.of(parseTypeSignature("array(T)")), false);
List<SqlScalarFunction> functions = ScalarFromAnnotationsParser.parseFunctionDefinition(ConstructorInjectionScalarFunction.class);
assertEquals(functions.size(), 1);
ParametricScalar scalar = (ParametricScalar) functions.get(0);
assertImplementationCount(scalar, 2, 0, 1);
List<ParametricScalarImplementationChoice> parametricScalarImplementationChoices = scalar.getImplementations().getGenericImplementations().get(0).getChoices();
assertEquals(parametricScalarImplementationChoices.size(), 1);
List<ImplementationDependency> dependencies = parametricScalarImplementationChoices.get(0).getDependencies();
assertEquals(dependencies.size(), 0);
List<ImplementationDependency> constructorDependencies = parametricScalarImplementationChoices.get(0).getConstructorDependencies();
assertEquals(constructorDependencies.size(), 1);
assertTrue(constructorDependencies.get(0) instanceof TypeImplementationDependency);
assertEquals(scalar.getSignature(), expectedSignature);
assertTrue(scalar.isDeterministic());
assertFalse(scalar.isHidden());
assertEquals(scalar.getDescription(), "Parametric scalar with type injected though constructor");
}
use of io.prestosql.operator.annotations.ImplementationDependency in project hetu-core by openlookeng.
the class TestAnnotationEngineForScalars method testSimpleInjectionScalarParse.
@Test
public void testSimpleInjectionScalarParse() {
Signature expectedSignature = new Signature(QualifiedObjectName.valueOfDefaultFunction("parametric_scalar_inject"), FunctionKind.SCALAR, ImmutableList.of(), ImmutableList.of(), BIGINT.getTypeSignature(), ImmutableList.of(parseTypeSignature("varchar(x)", ImmutableSet.of("x"))), false);
List<SqlScalarFunction> functions = ScalarFromAnnotationsParser.parseFunctionDefinition(SimpleInjectionScalarFunction.class);
assertEquals(functions.size(), 1);
ParametricScalar scalar = (ParametricScalar) functions.get(0);
assertImplementationCount(scalar, 0, 0, 1);
List<ParametricScalarImplementationChoice> parametricScalarImplementationChoices = scalar.getImplementations().getGenericImplementations().get(0).getChoices();
assertEquals(parametricScalarImplementationChoices.size(), 1);
List<ImplementationDependency> dependencies = parametricScalarImplementationChoices.get(0).getDependencies();
assertEquals(dependencies.size(), 1);
assertTrue(dependencies.get(0) instanceof LiteralImplementationDependency);
assertEquals(scalar.getSignature(), expectedSignature);
assertTrue(scalar.isDeterministic());
assertFalse(scalar.isHidden());
assertEquals(scalar.getDescription(), "Parametric scalar with literal injected");
}
use of io.prestosql.operator.annotations.ImplementationDependency in project hetu-core by openlookeng.
the class TestAnnotationEngineForScalars method testPartiallyFixedTypeParameterParse.
@Test
public void testPartiallyFixedTypeParameterParse() {
Signature expectedSignature = new Signature(QualifiedObjectName.valueOfDefaultFunction("partially_fixed_type_parameter_scalar_function"), FunctionKind.SCALAR, ImmutableList.of(typeVariable("T1"), typeVariable("T2")), ImmutableList.of(), BIGINT.getTypeSignature(), ImmutableList.of(BIGINT.getTypeSignature()), false);
List<SqlScalarFunction> functions = ScalarFromAnnotationsParser.parseFunctionDefinition(PartiallyFixedTypeParameterScalarFunction.class);
assertEquals(functions.size(), 1);
ParametricScalar scalar = (ParametricScalar) functions.get(0);
assertImplementationCount(scalar, 0, 0, 1);
List<ParametricScalarImplementationChoice> parametricScalarImplementationChoices = scalar.getImplementations().getGenericImplementations().get(0).getChoices();
assertEquals(parametricScalarImplementationChoices.size(), 1);
List<ImplementationDependency> dependencies = parametricScalarImplementationChoices.get(0).getDependencies();
assertEquals(dependencies.size(), 1);
assertEquals(scalar.getSignature(), expectedSignature);
assertTrue(scalar.isDeterministic());
assertFalse(scalar.isHidden());
assertEquals(scalar.getDescription(), "Parametric scalar that uses TypeParameter with partially fixed type");
}
Aggregations