prestodb/presto · error · SemanticException

FUNCTION_NOT_FOUND

FUNCTION_NOT_FOUND

Error message

FUNCTION_NOT_FOUND semantic error with cause message

What it means

During function resolution, ExpressionAnalyzer calls the function registry with qualified name and argument types. If the registry throws PrestoException with FUNCTION_NOT_FOUND (no signature matches), it is rethrown as a SemanticException FUNCTION_NOT_FOUND bound to the expression node, carrying the cause's message (e.g. 'Function not found: foo(varchar)').

Source

Thrown at presto-main-base/src/main/java/com/facebook/presto/sql/analyzer/ExpressionAnalyzer.java:1967

    }

    public static FunctionHandle resolveFunction(
            Optional<Map<SqlFunctionId, SqlInvokedFunction>> sessionFunctions,
            Optional<TransactionId> transactionId,
            FunctionCall node,
            List<TypeSignatureProvider> argumentTypes,
            FunctionAndTypeResolver functionAndTypeResolver)
    {
        try {
            return functionAndTypeResolver.resolveFunction(
                    sessionFunctions,
                    transactionId,
                    functionAndTypeResolver.qualifyObjectName(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 Map<NodeRef<Expression>, Type> getExpressionTypes(
            Session session,
            Metadata metadata,
            SqlParser sqlParser,
            TypeProvider types,
            Expression expression,
            Map<NodeRef<Parameter>, Expression> parameters,
            WarningCollector warningCollector)
    {
        return getExpressionTypes(session, metadata, sqlParser, types, expression, parameters, warningCollector, false);

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Fix the function name spelling/qualification in the query per the message's resolved signature
  2. Adjust argument types (add explicit CASTs) so they match an existing overload
  3. Install/enable the plugin providing the function, or switch to an available equivalent

Example fix

// before
SELECT array_distinct_agg(col) FROM t -- function not registered
// after
SELECT array_agg(DISTINCT col) FROM t -- use built-in equivalent
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-check function availability via system metadata
SELECT function_name FROM system.metadata.functions WHERE function_name = 'myfunc';

Try / catch

try {
    return session.execute(sql);
} catch (SemanticException e) {
    if (e.getCode() == SemanticErrorCode.FUNCTION_NOT_FOUND) {
        throw new IllegalStateException("Function missing or mistyped: " + e.getMessage(), e);
    }
    throw e;
}

Prevention

When it happens

Trigger: Calling an unqualified/misspelled function name, or a function whose argument types match no registered signature, when the SQL statement is analyzed.

Common situations: Typos in function names, using a function from a plugin not installed, wrong argument types for overloaded functions, session/catalog where the function does not exist.

Related errors


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