use of com.facebook.presto.operator.scalar.ParametricScalar in project presto by prestodb.
the class TestAnnotationEngineForScalars method testStaticMethodScalarParse.
@Test
public void testStaticMethodScalarParse() {
Signature expectedSignature = new Signature(QualifiedObjectName.valueOf(DEFAULT_NAMESPACE, "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());
assertEquals(scalar.getVisibility(), PUBLIC);
assertEquals(scalar.getDescription(), "Simple scalar with single implementation based on method");
}
use of com.facebook.presto.operator.scalar.ParametricScalar in project presto by prestodb.
the class TestAnnotationEngineForScalars method testParametricScalarParse.
@Test
public void testParametricScalarParse() {
Signature expectedSignature = new Signature(QualifiedObjectName.valueOf(DEFAULT_NAMESPACE, "parametric_scalar"), FunctionKind.SCALAR, ImmutableList.of(typeVariable("T")), ImmutableList.of(), parseTypeSignature("T"), ImmutableList.of(parseTypeSignature("T")), false);
List<SqlScalarFunction> functions = ScalarFromAnnotationsParser.parseFunctionDefinition(ParametricScalarFunction.class);
assertEquals(functions.size(), 1);
ParametricScalar scalar = (ParametricScalar) functions.get(0);
assertImplementationCount(scalar, 0, 2, 0);
assertEquals(scalar.getSignature(), expectedSignature);
assertTrue(scalar.isDeterministic());
assertEquals(scalar.getVisibility(), PUBLIC);
assertEquals(scalar.getDescription(), "Parametric scalar description");
}
use of com.facebook.presto.operator.scalar.ParametricScalar in project presto by prestodb.
the class TestAnnotationEngineForScalars method testNonDeterministicScalarParse.
@Test
public void testNonDeterministicScalarParse() {
List<SqlScalarFunction> functions = ScalarFromAnnotationsParser.parseFunctionDefinition(NonDeterministicScalarFunction.class);
assertEquals(functions.size(), 1);
ParametricScalar scalar = (ParametricScalar) functions.get(0);
assertFalse(scalar.isDeterministic());
assertEquals(scalar.getVisibility(), PUBLIC);
}
use of com.facebook.presto.operator.scalar.ParametricScalar in project presto by prestodb.
the class TestAnnotationEngineForScalars method testWithNullableComplexArgScalarParse.
@Test
public void testWithNullableComplexArgScalarParse() {
Signature expectedSignature = new Signature(QualifiedObjectName.valueOf(DEFAULT_NAMESPACE, "scalar_with_nullable_complex"), FunctionKind.SCALAR, DOUBLE.getTypeSignature(), ImmutableList.of(DOUBLE.getTypeSignature(), DOUBLE.getTypeSignature()));
List<SqlScalarFunction> functions = ScalarFromAnnotationsParser.parseFunctionDefinition(WithNullableComplexArgScalarFunction.class);
assertEquals(functions.size(), 1);
ParametricScalar scalar = (ParametricScalar) functions.get(0);
assertEquals(scalar.getSignature(), expectedSignature);
assertTrue(scalar.isDeterministic());
assertEquals(scalar.getVisibility(), PUBLIC);
assertEquals(scalar.getDescription(), "Simple scalar with nullable complex type");
BuiltInScalarFunctionImplementation specialized = scalar.specialize(BoundVariables.builder().build(), 2, FUNCTION_AND_TYPE_MANAGER);
assertFalse(specialized.getInstanceFactory().isPresent());
assertEquals(specialized.getArgumentProperty(0), valueTypeArgumentProperty(RETURN_NULL_ON_NULL));
assertEquals(specialized.getArgumentProperty(1), valueTypeArgumentProperty(USE_BOXED_TYPE));
}
use of com.facebook.presto.operator.scalar.ParametricScalar in project presto by prestodb.
the class TestAnnotationEngineForScalars method testHiddenScalarParse.
@Test
public void testHiddenScalarParse() {
List<SqlScalarFunction> functions = ScalarFromAnnotationsParser.parseFunctionDefinition(HiddenScalarFunction.class);
assertEquals(functions.size(), 1);
ParametricScalar scalar = (ParametricScalar) functions.get(0);
assertTrue(scalar.isDeterministic());
assertEquals(scalar.getVisibility(), HIDDEN);
}
Aggregations