{"record":{"id":"61c3447cbf8b3dc6","repo":"prestodb/presto","slug":"failed-to-find-matching-function-signature-for-s","errorCode":null,"errorMessage":"Failed to find matching function signature for %s, matching failures: ","messagePattern":"Failed to find matching function signature for (.+?), matching failures: ","errorType":"error_code","errorClass":"SignatureMatchingException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/metadata/FunctionSignatureMatcher.java","lineNumber":365,"sourceCode":"                }\n            }\n        }\n        return true;\n    }\n\n    /**\n     * Decides which exception to throw based on the number of failed attempts.\n     * If there's only one SemanticException, it throws that SemanticException directly.\n     * If there are multiple SemanticExceptions, it throws the SignatureMatchingException.\n     */\n    public static void decideAndThrow(List<SemanticException> failedExceptions, String functionName)\n            throws SemanticException\n    {\n        if (failedExceptions.size() == 1) {\n            throw failedExceptions.get(0);\n        }\n        else {\n            throw new SignatureMatchingException(format(\"Failed to find matching function signature for %s, matching failures: \", functionName), failedExceptions);\n        }\n    }\n\n    static String constructFunctionNotFoundErrorMessage(QualifiedObjectName functionName, List<TypeSignatureProvider> parameterTypes, Collection<? extends SqlFunction> candidates)\n    {\n        String name = toConciseFunctionName(functionName);\n        List<String> expectedParameters = new ArrayList<>();\n        for (SqlFunction function : candidates) {\n            expectedParameters.add(format(\"%s(%s) %s\",\n                    name,\n                    Joiner.on(\", \").join(function.getSignature().getArgumentTypes()),\n                    Joiner.on(\", \").join(function.getSignature().getTypeVariableConstraints())));\n        }\n        String parameters = Joiner.on(\", \").join(parameterTypes);\n        String message = format(\"Function %s not registered\", name);\n        if (!expectedParameters.isEmpty()) {\n            String expected = Joiner.on(\", \").join(expectedParameters);\n            message = format(\"Unexpected parameters (%s) for function %s. Expected: %s\", parameters, name, expected);","sourceCodeStart":347,"sourceCodeEnd":383,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/metadata/FunctionSignatureMatcher.java#L347-L383","documentation":"decideAndThrow is the terminal failure point of function signature matching. If exactly one underlying failure occurred it rethrows that original exception; otherwise it aggregates all per-candidate SignatureMatchingExceptions into one SignatureMatchingException listing every reason the function signature could not be matched. Unlike the AMBIGUOUS_FUNCTION_CALL errors, this fires when nothing matched, not when several things matched.","triggerScenarios":"identifyApplicableFunctions tried all candidate signatures for a function name and each failed for a (possibly different) reason — type mismatches, wrong arity, etc. — producing multiple failedExceptions.","commonSituations":"Calling a function with the wrong number of arguments across all overloads; arguments whose types no overload accepts; connector-qualified functions not found with parameters matching any candidate; complex calls where each overload fails differently so only the aggregate message appears.","solutions":["Read the aggregated 'matching failures' list to see why each candidate was rejected","Fix argument count/types to match one candidate signature, adding CASTs as needed","Verify the function exists in the target catalog with the expected signature (SHOW FUNCTIONS)","If authoring the UDF, add an overload accepting the types being passed"],"exampleFix":"// before\nSELECT date_diff('day', '2024-01-01', now()); -- no overload accepts varchar timestamp\n// after\nSELECT date_diff('day', DATE '2024-01-01', now());","handlingStrategy":"try-catch","validationCode":"// Validate arity and basic type compatibility before resolution:\nif (candidates.stream().noneMatch(c -> c.getSignature().getArgumentTypes().size() == args.size())) {\n    throw new IllegalStateException(\"Wrong argument count for \" + functionName);\n}","typeGuard":null,"tryCatchPattern":"try { applicable = identifyApplicableFunctions(candidates, args); }\ncatch (SignatureMatchingException e) { /* inspect e.getFailures() and report each reason */ }","preventionTips":["Match argument count and types to a documented overload (SHOW FUNCTIONS / docs)","CAST arguments to the exact declared types of the intended overload","Don't pass NULL untyped — use CAST(NULL AS <type>)","When authoring UDFs, add overloads for common type combinations"],"tags":["presto","function-resolution","sql"],"backgroundTag":"function-signature-mismatch","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}