prestodb/presto · error · PrestoException

AMBIGUOUS_FUNCTION_CALL

AMBIGUOUS_FUNCTION_CALL

Error message

Function '%s' has two matching signatures. Please specify parameter types. 
First match : '%s', Second match: '%s'

What it means

When both the default (builtin) namespace and the plugin namespace contain a matching overload for the same function call, Presto refuses to silently pick one and throws AMBIGUOUS_FUNCTION_CALL listing both matching signatures, asking the user to specify parameter types.

Source

Thrown at presto-main-base/src/main/java/com/facebook/presto/metadata/FunctionAndTypeManager.java:1173

            matchingWorkerFunctionSignature =
                    getMatchingFunction(workerCandidates, parameterTypes, coercionAllowed);
            if (matchingWorkerFunctionSignature.isPresent()) {
                foundMatch = true;
            }
        }
        catch (SemanticException e) {
            exceptions.add(e);
        }

        if (!foundMatch && !exceptions.isEmpty()) {
            decideAndThrow(exceptions,
                    allCandidates.stream().findFirst()
                            .map(function -> function.getSignature().getName().getObjectName())
                            .orElse(""));
        }

        if (matchingDefaultFunctionSignature.isPresent() && matchingPluginFunctionSignature.isPresent()) {
            throw new PrestoException(AMBIGUOUS_FUNCTION_CALL, format("Function '%s' has two matching signatures. Please specify parameter types. \n" +
                    "First match : '%s', Second match: '%s'", functionName, matchingDefaultFunctionSignature.get(), matchingPluginFunctionSignature.get()));
        }

        if (matchingDefaultFunctionSignature.isPresent() && matchingWorkerFunctionSignature.isPresent()) {
            FunctionHandle defaultFunctionHandle = functionNamespaceManager.getFunctionHandle(transactionHandle, matchingDefaultFunctionSignature.get());
            FunctionHandle workerFunctionHandle = builtInWorkerFunctionNamespaceManager.getFunctionHandle(transactionHandle, matchingWorkerFunctionSignature.get());

            if (functionNamespaceManager.getFunctionMetadata(defaultFunctionHandle).getImplementationType().equals(FunctionImplementationType.JAVA)) {
                return defaultFunctionHandle;
            }
            if (functionNamespaceManager.getFunctionMetadata(defaultFunctionHandle).getImplementationType().equals(FunctionImplementationType.SQL)) {
                return workerFunctionHandle;
            }
        }

        if (matchingPluginFunctionSignature.isPresent() && matchingWorkerFunctionSignature.isPresent()) {
            // built in plugin function namespace manager always has SQL as implementation type
            return builtInWorkerFunctionNamespaceManager.getFunctionHandle(transactionHandle, matchingWorkerFunctionSignature.get());

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Qualify the call to the intended namespace/catalog.schema so only one candidate matches
  2. Add explicit CASTs on arguments to steer matching to a single signature
  3. Rename/unregister the plugin function that collides with the builtin
  4. Upgrade or downgrade the plugin so it no longer duplicates the builtin

Example fix

// before
SELECT greatest(1, 2) -- matches builtin AND plugin 'greatest'
// after
SELECT builtin.default.greatest(1, 2) -- or uninstall the colliding plugin function
Defensive patterns

Strategy: validation

Validate before calling

// before calling, fully qualify the function name with its namespace so only one candidate can match

Try / catch

try { fam.resolveFunction(name, types); } catch (PrestoException e) { if (e.getErrorCode().getCode() == AMBIGUOUS_FUNCTION_CALL) { /* read both signatures from message and disambiguate via casts or qualification */ } }

Prevention

When it happens

Trigger: resolveFunction path where matchingDefaultFunctionSignature and matchingPluginFunctionSignature are both present — i.e., the same function name/arity is registered in both builtin and plugin namespaces and both match the given argument types.

Common situations: A plugin registers a function whose name collides with a builtin (e.g. after a Presto upgrade added the builtin); shadowed function names across plugin versions; user SQL calls the colliding name without disambiguation.

Related errors


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