prestodb/presto · error · PrestoException

FUNCTION_NOT_FOUND

FUNCTION_NOT_FOUND

Error message

Function not found: %s%s

What it means

SHOW CREATE FUNCTION <name>[types] found no function matching the given name and (optionally) parameter types. The resolver returned an empty function list after optional filtering by argument types, so Presto throws FUNCTION_NOT_FOUND. The name may exist but with different argument types than those specified.

Source

Thrown at presto-main-base/src/main/java/com/facebook/presto/sql/rewrite/ShowQueriesRewrite.java:660

            throw new UnsupportedOperationException("SHOW CREATE only supported for tables and views");
        }

        @Override
        protected Node visitShowCreateFunction(ShowCreateFunction node, Void context)
        {
            QualifiedObjectName functionName = metadata.getFunctionAndTypeManager().getFunctionAndTypeResolver().qualifyObjectName(node.getName());
            Collection<? extends SqlFunction> functions = metadata.getFunctionAndTypeManager().getFunctions(session, functionName);
            if (node.getParameterTypes().isPresent()) {
                List<TypeSignature> parameterTypes = node.getParameterTypes().get().stream()
                        .map(TypeSignature::parseTypeSignature)
                        .collect(toImmutableList());
                functions = functions.stream()
                        .filter(function -> function.getSignature().getArgumentTypes().equals(parameterTypes))
                        .collect(toImmutableList());
            }
            if (functions.isEmpty()) {
                String types = node.getParameterTypes().map(parameterTypes -> format("(%s)", Joiner.on(", ").join(parameterTypes))).orElse("");
                throw new PrestoException(FUNCTION_NOT_FOUND, format("Function not found: %s%s", functionName, types));
            }

            ImmutableList.Builder<Expression> rows = ImmutableList.builder();
            for (SqlFunction function : functions) {
                if (!(function instanceof SqlInvokedFunction)) {
                    throw new PrestoException(GENERIC_USER_ERROR, "SHOW CREATE FUNCTION is only supported for SQL functions");
                }

                SqlInvokedFunction sqlFunction = (SqlInvokedFunction) function;
                boolean temporary = sqlFunction.getFunctionId().getFunctionName().getCatalogSchemaName().equals(SESSION_NAMESPACE);
                CreateFunction createFunction = new CreateFunction(
                        node.getName(),
                        false,
                        temporary,
                        sqlFunction.getParameters().stream()
                                .map(parameter -> new SqlParameterDeclaration(new Identifier(parameter.getName()), parameter.getType().toString()))
                                .collect(toImmutableList()),
                        sqlFunction.getSignature().getReturnType().toString(),

View on GitHub (pinned to 55bb57d202)

Solutions

  1. List available functions with SHOW FUNCTIONS and copy the exact name and signature
  2. Fully qualify the function name (catalog.schema.function) if it is not a built-in
  3. Match the declared parameter types exactly when using the (types) form, or omit the types clause to match any overload
  4. Create the function first with CREATE FUNCTION if it does not exist

Example fix

// before
SHOW CREATE FUNCTION my_avg(varchar)
// after (overload takes double, per SHOW FUNCTIONS)
SHOW CREATE FUNCTION my_avg(double)
Defensive patterns

Strategy: validation

Validate before calling

-- verify name and signature first
SELECT function_name, argument_types, return_type FROM information_schema.functions
WHERE function_name = 'my_avg';

Try / catch

try { session.execute("SHOW CREATE FUNCTION " + sig); } catch (PrestoException e) { if (e.getErrorCode() == FUNCTION_NOT_FOUND.toErrorCode()) { /* list overloads via SHOW FUNCTIONS */ } throw e; }

Prevention

When it happens

Trigger: SHOW CREATE FUNCTION for a misspelled or unqualified function name, a function living in another schema, or a correct name with parameterTypes that match no overload (e.g. (varchar) when only (double) exists).

Common situations: Catalog/schema-qualified name required but omitted; overload resolution mistakes with numeric vs varchar args; function exists only in the session namespace of another session; built-in (non-SQL) functions whose definitions cannot be shown anyway.

Related errors


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