prestodb/presto · error · PrestoException

AMBIGUOUS_FUNCTION_CALL

AMBIGUOUS_FUNCTION_CALL

Error message

Function '%s' has multiple signatures: %s. Please specify parameter types.

What it means

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.

Source

Thrown at presto-function-namespace-managers/src/main/java/com/facebook/presto/functionNamespace/mysql/MySqlFunctionNamespaceManager.java:309

    {
        return parseLong(function.getRequiredVersion());
    }

    private static void checkFieldLength(String fieldName, String field, int maxLength)
    {
        if (field.length() > maxLength) {
            throw new PrestoException(GENERIC_USER_ERROR, format("%s exceeds max length of %s: %s", fieldName, maxLength, field));
        }
    }

    private static void checkUnique(List<SqlInvokedFunction> functions, QualifiedObjectName functionName)
    {
        if (functions.size() > 1) {
            String signatures = functions.stream()
                    .map(SqlFunction::getSignature)
                    .map(Signature::toString)
                    .collect(joining("; "));
            throw new PrestoException(AMBIGUOUS_FUNCTION_CALL, format("Function '%s' has multiple signatures: %s. Please specify parameter types.", functionName, signatures));
        }
    }

    private static void checkExists(List<SqlInvokedFunction> functions, QualifiedObjectName functionName, Optional<List<TypeSignature>> parameterTypes)
    {
        if (functions.isEmpty()) {
            String formattedParameterTypes = parameterTypes.map(types -> types.stream()
                    .map(TypeSignature::toString)
                    .collect(joining(",", "(", ")"))).orElse("");
            throw new PrestoException(NOT_FOUND, format("Function not found: %s%s", functionName, formattedParameterTypes));
        }
    }

    private static String hash(SqlFunctionId functionId)
    {
        return sha256().hashString(functionId.toString(), UTF_8).toString();
    }
}

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Re-run the ALTER FUNCTION specifying parameter types, e.g. ALTER FUNCTION catalog.schema.fn(int) ...
  2. Drop the unwanted overload(s) with DROP FUNCTION including explicit parameter types so only one signature remains
  3. List existing signatures with SHOW FUNCTIONS LIKE 'fn' to see which overloads exist before altering

Example fix

// before
ALTER FUNCTION catalog.schema.fn SET PROPERTIES LANGUAGE=SQL
// after
ALTER FUNCTION catalog.schema.fn(varchar, bigint) SET PROPERTIES LANGUAGE=SQL
Defensive patterns

Strategy: validation

Validate before calling

List<SqlInvokedFunction> existing = manager.getFunctions(functionName);
if (existing.size() > 1) {
    throw new IllegalStateException("Ambiguous function " + functionName + ": specify parameter types");
}

Try / catch

try {
    manager.alterFunction(functionName, parameterTypes, characteristics);
} catch (PrestoException e) {
    if (e.getErrorCode().getCode() == AMBIGUOUS_FUNCTION_CALL.toErrorCode().getCode()) {
        // parse signatures from the message and retry with parameterTypes set
    } else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/da61d8d2984643ac. Report an issue: GitHub.