Prevent ExpressionOptimizer from optimizing 'fail' function
Optimizing 'fail' function leads to infinite looping when using
expression optimizer in iterative optimizer.
Also, there is nothing that can be optimized in 'fail' case.
@@ -966,7 +966,7 @@ public class ExpressionInterpreter
}
// do not optimize non-deterministic functions
- if (optimize && (!function.isDeterministic() || hasUnresolvedValue(argumentValues))) {
+ if (optimize && (!function.isDeterministic() || hasUnresolvedValue(argumentValues) || node.getName().equals(QualifiedName.of("fail")))) {
return new FunctionCall(node.getName(), node.getWindow(), node.isDistinct(), toExpressions(argumentValues, argumentTypes));
}
return functionInvoker.invoke(functionSignature, session, argumentValues);
