use of com.facebook.presto.spi.function.JavaScalarFunctionImplementation in project presto by prestodb.
the class ArrayToArrayCast method specialize.
@Override
public BuiltInScalarFunctionImplementation specialize(BoundVariables boundVariables, int arity, FunctionAndTypeManager functionAndTypeManager) {
checkArgument(arity == 1, "Expected arity to be 1");
Type fromType = boundVariables.getTypeVariable("F");
Type toType = boundVariables.getTypeVariable("T");
FunctionHandle functionHandle = functionAndTypeManager.lookupCast(CastType.CAST, fromType.getTypeSignature(), toType.getTypeSignature());
JavaScalarFunctionImplementation function = functionAndTypeManager.getJavaScalarFunctionImplementation(functionHandle);
Class<?> castOperatorClass = generateArrayCast(functionAndTypeManager, functionAndTypeManager.getFunctionMetadata(functionHandle), function);
MethodHandle methodHandle = methodHandle(castOperatorClass, "castArray", SqlFunctionProperties.class, Block.class);
return new BuiltInScalarFunctionImplementation(false, ImmutableList.of(valueTypeArgumentProperty(RETURN_NULL_ON_NULL), valueTypeArgumentProperty(RETURN_NULL_ON_NULL)), methodHandle);
}
use of com.facebook.presto.spi.function.JavaScalarFunctionImplementation in project presto by prestodb.
the class FunctionAndTypeManager method getJavaScalarFunctionImplementation.
public JavaScalarFunctionImplementation getJavaScalarFunctionImplementation(FunctionHandle functionHandle) {
ScalarFunctionImplementation implementation = getScalarFunctionImplementation(functionHandle);
checkArgument(implementation instanceof JavaScalarFunctionImplementation, format("Implementation of function %s is not a JavaScalarFunctionImplementation", getFunctionMetadata(functionHandle).getName()));
return (JavaScalarFunctionImplementation) implementation;
}
Aggregations