// do not optimize non-deterministic functions
if (optimize && !function.isDeterministic()) {
return new FunctionCall(node.getName(), node.getWindow().orNull(), node.isDistinct(), toExpressions(argumentValues));
}
MethodHandle handle = function.getScalarFunction();
if (handle.type().parameterCount() > 0 && handle.type().parameterType(0) == Session.class) {
handle = handle.bindTo(session);
}
try {
return handle.invokeWithArguments(argumentValues);
}