{"record":{"id":"da61d8d2984643ac","repo":"prestodb/presto","slug":"ambiguous-function-call","errorCode":"AMBIGUOUS_FUNCTION_CALL","errorMessage":"Function '%s' has multiple signatures: %s. Please specify parameter types.","messagePattern":"Function '(.+?)' has multiple signatures: (.+?)\\. Please specify parameter types\\.","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-function-namespace-managers/src/main/java/com/facebook/presto/functionNamespace/mysql/MySqlFunctionNamespaceManager.java","lineNumber":309,"sourceCode":"    {\n        return parseLong(function.getRequiredVersion());\n    }\n\n    private static void checkFieldLength(String fieldName, String field, int maxLength)\n    {\n        if (field.length() > maxLength) {\n            throw new PrestoException(GENERIC_USER_ERROR, format(\"%s exceeds max length of %s: %s\", fieldName, maxLength, field));\n        }\n    }\n\n    private static void checkUnique(List<SqlInvokedFunction> functions, QualifiedObjectName functionName)\n    {\n        if (functions.size() > 1) {\n            String signatures = functions.stream()\n                    .map(SqlFunction::getSignature)\n                    .map(Signature::toString)\n                    .collect(joining(\"; \"));\n            throw new PrestoException(AMBIGUOUS_FUNCTION_CALL, format(\"Function '%s' has multiple signatures: %s. Please specify parameter types.\", functionName, signatures));\n        }\n    }\n\n    private static void checkExists(List<SqlInvokedFunction> functions, QualifiedObjectName functionName, Optional<List<TypeSignature>> parameterTypes)\n    {\n        if (functions.isEmpty()) {\n            String formattedParameterTypes = parameterTypes.map(types -> types.stream()\n                    .map(TypeSignature::toString)\n                    .collect(joining(\",\", \"(\", \")\"))).orElse(\"\");\n            throw new PrestoException(NOT_FOUND, format(\"Function not found: %s%s\", functionName, formattedParameterTypes));\n        }\n    }\n\n    private static String hash(SqlFunctionId functionId)\n    {\n        return sha256().hashString(functionId.toString(), UTF_8).toString();\n    }\n}","sourceCodeStart":291,"sourceCodeEnd":327,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-function-namespace-managers/src/main/java/com/facebook/presto/functionNamespace/mysql/MySqlFunctionNamespaceManager.java#L291-L327","documentation":"checkUnique in MySqlFunctionNamespaceManager throws AMBIGUOUS_FUNCTION_CALL when an ALTER FUNCTION targets a function name that resolves to more than one stored signature and no parameter types were given to disambiguate. The manager needs exactly one matching function to alter, so it refuses to guess. The message lists all colliding signatures.","triggerScenarios":"Running ALTER FUNCTION on an overloaded function name (same schema.name with different parameter type lists) without specifying parameter types in the routine characteristics / WITH clause.","commonSituations":"Users who previously created overloaded UDFs (e.g. fn(int) and fn(varchar)) then tried to alter 'fn' generically; scripts migrated from engines where overloads were not allowed.","solutions":["Re-run the ALTER FUNCTION specifying parameter types, e.g. ALTER FUNCTION catalog.schema.fn(int) ...","Drop the unwanted overload(s) with DROP FUNCTION including explicit parameter types so only one signature remains","List existing signatures with SHOW FUNCTIONS LIKE 'fn' to see which overloads exist before altering"],"exampleFix":"// before\nALTER FUNCTION catalog.schema.fn SET PROPERTIES LANGUAGE=SQL\n// after\nALTER FUNCTION catalog.schema.fn(varchar, bigint) SET PROPERTIES LANGUAGE=SQL","handlingStrategy":"validation","validationCode":"List<SqlInvokedFunction> existing = manager.getFunctions(functionName);\nif (existing.size() > 1) {\n    throw new IllegalStateException(\"Ambiguous function \" + functionName + \": specify parameter types\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    manager.alterFunction(functionName, parameterTypes, characteristics);\n} catch (PrestoException e) {\n    if (e.getErrorCode().getCode() == AMBIGUOUS_FUNCTION_CALL.toErrorCode().getCode()) {\n        // parse signatures from the message and retry with parameterTypes set\n    } else throw e;\n}","preventionTips":["Always qualify ALTER/DROP with explicit parameter types when overloads may exist","Run SHOW FUNCTIONS LIKE '<name>' to enumerate overloads before altering","Avoid creating overloaded UDFs when your tooling only alters by name"],"tags":["ambiguity","function-overload","mysql","function-namespace"],"backgroundTag":"ambiguous-function-overload","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"}