Extract function resolution code to separate method
@@ -789,19 +789,7 @@ public class ExpressionAnalyzer
}
ImmutableList<TypeSignatureProvider> argumentTypes = argumentTypesBuilder.build();
- Signature function;
- try {
- function = functionRegistry.resolveFunction(node.getName(), argumentTypes);
- }
- catch (PrestoException e) {
- if (e.getErrorCode().getCode() == StandardErrorCode.FUNCTION_NOT_FOUND.toErrorCode().getCode()) {
- throw new SemanticException(SemanticErrorCode.FUNCTION_NOT_FOUND, node, e.getMessage());
- }
- if (e.getErrorCode().getCode() == StandardErrorCode.AMBIGUOUS_FUNCTION_CALL.toErrorCode().getCode()) {
- throw new SemanticException(SemanticErrorCode.AMBIGUOUS_FUNCTION_CALL, node, e.getMessage());
- }
- throw e;
- }
+ Signature function = resolveFunction(node, argumentTypes, functionRegistry);
for (int i = 0; i < node.getArguments().size(); i++) {
Expression expression = node.getArguments().get(i);
@@ -1286,6 +1274,22 @@ public class ExpressionAnalyzer
}
}
+ public static Signature resolveFunction(FunctionCall node, List<TypeSignatureProvider> argumentTypes, FunctionRegistry functionRegistry)
+ {
+ try {
+ return functionRegistry.resolveFunction(node.getName(), argumentTypes);
+ }
+ catch (PrestoException e) {
+ if (e.getErrorCode().getCode() == StandardErrorCode.FUNCTION_NOT_FOUND.toErrorCode().getCode()) {
+ throw new SemanticException(SemanticErrorCode.FUNCTION_NOT_FOUND, node, e.getMessage());
+ }
+ if (e.getErrorCode().getCode() == StandardErrorCode.AMBIGUOUS_FUNCTION_CALL.toErrorCode().getCode()) {
+ throw new SemanticException(SemanticErrorCode.AMBIGUOUS_FUNCTION_CALL, node, e.getMessage());
+ }
+ throw e;
+ }
+ }
+
public static IdentityLinkedHashMap<Expression, Type> getExpressionTypes(
Session session,
Metadata metadata,
