use of io.prestosql.metadata.TestPolymorphicScalarFunction.TestMethods.VARCHAR_TO_VARCHAR_RETURN_VALUE in project hetu-core by openlookeng.
the class TestPolymorphicScalarFunction method testSameLiteralInArgumentsAndReturnValue.
@Test
public void testSameLiteralInArgumentsAndReturnValue() throws Throwable {
Signature signature = Signature.builder().name("foo").kind(SCALAR).returnType(parseTypeSignature("varchar(x)", ImmutableSet.of("x"))).argumentTypes(parseTypeSignature("varchar(x)", ImmutableSet.of("x"))).build();
SqlScalarFunction function = SqlScalarFunction.builder(TestMethods.class).signature(signature).deterministic(true).calledOnNullInput(FOO_IS_CALL_ON_NUL_INPUT).choice(choice -> choice.implementation(methodsGroup -> methodsGroup.methods("varcharToVarchar"))).build();
BuiltInScalarFunctionImplementation functionImplementation = function.specialize(BOUND_VARIABLES, 1, METADATA.getFunctionAndTypeManager());
Slice slice = (Slice) functionImplementation.getMethodHandle().invoke(INPUT_SLICE);
assertEquals(slice, VARCHAR_TO_VARCHAR_RETURN_VALUE);
}
use of io.prestosql.metadata.TestPolymorphicScalarFunction.TestMethods.VARCHAR_TO_VARCHAR_RETURN_VALUE in project hetu-core by openlookeng.
the class TestPolymorphicScalarFunction method testTypeParameters.
@Test
public void testTypeParameters() throws Throwable {
Signature signature = Signature.builder().name("foo").kind(SCALAR).typeVariableConstraints(comparableWithVariadicBound("V", VARCHAR)).returnType(parseTypeSignature("V")).argumentTypes(parseTypeSignature("V")).build();
SqlScalarFunction function = SqlScalarFunction.builder(TestMethods.class).signature(signature).deterministic(true).calledOnNullInput(FOO_IS_CALL_ON_NUL_INPUT).choice(choice -> choice.implementation(methodsGroup -> methodsGroup.methods("varcharToVarchar"))).build();
BuiltInScalarFunctionImplementation functionImplementation = function.specialize(BOUND_VARIABLES, 1, METADATA.getFunctionAndTypeManager());
Slice slice = (Slice) functionImplementation.getMethodHandle().invoke(INPUT_SLICE);
assertEquals(slice, VARCHAR_TO_VARCHAR_RETURN_VALUE);
}
Aggregations