use of io.prestosql.operator.scalar.ParametricScalar in project hetu-core by openlookeng.
the class TestAnnotationEngineForScalars method testSingleImplementationScalarParse.
@Test
public void testSingleImplementationScalarParse() {
Signature expectedSignature = new Signature(QualifiedObjectName.valueOfDefaultFunction("single_implementation_parametric_scalar"), FunctionKind.SCALAR, DOUBLE.getTypeSignature(), ImmutableList.of(DOUBLE.getTypeSignature()));
List<SqlScalarFunction> functions = ScalarFromAnnotationsParser.parseFunctionDefinition(SingleImplementationScalarFunction.class);
assertEquals(functions.size(), 1);
ParametricScalar scalar = (ParametricScalar) functions.get(0);
assertEquals(scalar.getSignature(), expectedSignature);
assertTrue(scalar.isDeterministic());
assertFalse(scalar.isHidden());
assertEquals(scalar.getDescription(), "Simple scalar with single implementation based on class");
assertImplementationCount(scalar, 1, 0, 0);
BuiltInScalarFunctionImplementation specialized = scalar.specialize(BoundVariables.builder().build(), 1, METADATA.getFunctionAndTypeManager());
assertFalse(specialized.getInstanceFactory().isPresent());
assertEquals(specialized.getArgumentProperty(0).getNullConvention(), RETURN_NULL_ON_NULL);
}
use of io.prestosql.operator.scalar.ParametricScalar in project hetu-core by openlookeng.
the class TestAnnotationEngineForScalars method testStaticMethodScalarParse.
@Test
public void testStaticMethodScalarParse() {
Signature expectedSignature = new Signature(QualifiedObjectName.valueOfDefaultFunction("static_method_scalar"), FunctionKind.SCALAR, DOUBLE.getTypeSignature(), ImmutableList.of(DOUBLE.getTypeSignature()));
List<SqlScalarFunction> functions = ScalarFromAnnotationsParser.parseFunctionDefinitions(StaticMethodScalarFunction.class);
assertEquals(functions.size(), 1);
ParametricScalar scalar = (ParametricScalar) functions.get(0);
assertEquals(scalar.getSignature(), expectedSignature);
assertTrue(scalar.isDeterministic());
assertFalse(scalar.isHidden());
assertEquals(scalar.getDescription(), "Simple scalar with single implementation based on method");
}
use of io.prestosql.operator.scalar.ParametricScalar in project hetu-core by openlookeng.
the class TestAnnotationEngineForScalars method testFixedTypeParameterParse.
@Test
public void testFixedTypeParameterParse() {
Signature expectedSignature = new Signature(QualifiedObjectName.valueOfDefaultFunction("fixed_type_parameter_scalar_function"), FunctionKind.SCALAR, ImmutableList.of(), ImmutableList.of(), BIGINT.getTypeSignature(), ImmutableList.of(BIGINT.getTypeSignature()), false);
List<SqlScalarFunction> functions = ScalarFromAnnotationsParser.parseFunctionDefinition(FixedTypeParameterScalarFunction.class);
assertEquals(functions.size(), 1);
ParametricScalar scalar = (ParametricScalar) functions.get(0);
assertImplementationCount(scalar, 1, 0, 0);
assertEquals(scalar.getSignature(), expectedSignature);
assertTrue(scalar.isDeterministic());
assertFalse(scalar.isHidden());
assertEquals(scalar.getDescription(), "Parametric scalar that uses TypeParameter with fixed type");
}
use of io.prestosql.operator.scalar.ParametricScalar in project hetu-core by openlookeng.
the class TestAnnotationEngineForScalars method testComplexParametricScalarParse.
@Test
public void testComplexParametricScalarParse() {
Signature expectedSignature = new Signature(QualifiedObjectName.valueOfDefaultFunction("with_exact_scalar"), FunctionKind.SCALAR, ImmutableList.of(), ImmutableList.of(), BOOLEAN.getTypeSignature(), ImmutableList.of(parseTypeSignature("array(varchar(x))", ImmutableSet.of("x"))), false);
Signature exactSignature = new Signature(QualifiedObjectName.valueOfDefaultFunction("with_exact_scalar"), FunctionKind.SCALAR, ImmutableList.of(), ImmutableList.of(), BOOLEAN.getTypeSignature(), ImmutableList.of(parseTypeSignature("array(varchar(17))")), false);
List<SqlScalarFunction> functions = ScalarFromAnnotationsParser.parseFunctionDefinition(ComplexParametricScalarFunction.class);
assertEquals(functions.size(), 1);
ParametricScalar scalar = (ParametricScalar) functions.get(0);
assertImplementationCount(scalar.getImplementations(), 1, 0, 1);
assertEquals(getOnlyElement(scalar.getImplementations().getExactImplementations().keySet()), exactSignature);
assertEquals(scalar.getSignature(), expectedSignature);
assertTrue(scalar.isDeterministic());
assertFalse(scalar.isHidden());
assertEquals(scalar.getDescription(), "Parametric scalar with exact and generic implementations");
}
Aggregations