use of io.prestosql.metadata.TestPolymorphicScalarFunction.TestMethods.VARCHAR_TO_BIGINT_RETURN_VALUE in project hetu-core by openlookeng.
the class TestPolymorphicScalarFunction method testSelectsMethodBasedOnReturnType.
@Test
public void testSelectsMethodBasedOnReturnType() throws Throwable {
SqlScalarFunction function = SqlScalarFunction.builder(TestMethods.class).signature(SIGNATURE).deterministic(true).calledOnNullInput(FOO_IS_CALL_ON_NUL_INPUT).choice(choice -> choice.implementation(methodsGroup -> methodsGroup.methods("varcharToVarcharCreateSliceWithExtraParameterLength")).implementation(methodsGroup -> methodsGroup.methods("varcharToBigintReturnExtraParameter").withExtraParameters(context -> ImmutableList.of(42)))).build();
BuiltInScalarFunctionImplementation functionImplementation = function.specialize(BOUND_VARIABLES, 1, METADATA.getFunctionAndTypeManager());
assertEquals(functionImplementation.getMethodHandle().invoke(INPUT_SLICE), VARCHAR_TO_BIGINT_RETURN_VALUE);
}
Aggregations