prestodb/presto · error · PrestoException

GENERIC_USER_ERROR

GENERIC_USER_ERROR

Error message

Function has more than %s parameters: %s

What it means

createFunction enforces a maximum parameter count (MAX_PARAMETER_COUNT) per SQL-invoked function to keep stored signatures within MySQL field/row limits and sane query planning. Exceeding it throws GENERIC_USER_ERROR.

Source

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

    }

    @Override
    public void createFunction(SqlInvokedFunction function, boolean replace)
    {
        checkCatalog(function);
        checkFunctionLanguageSupported(function);
        checkArgument(!function.hasVersion(), "function '%s' is already versioned", function);

        QualifiedObjectName functionName = function.getFunctionId().getFunctionName();
        checkFieldLength("Catalog name", functionName.getCatalogName(), MAX_CATALOG_NAME_LENGTH);
        checkFieldLength("Schema name", functionName.getSchemaName(), MAX_SCHEMA_NAME_LENGTH);
        if (!functionNamespaceDao.functionNamespaceExists(functionName.getCatalogName(), functionName.getSchemaName())) {
            throw new PrestoException(NOT_FOUND, format("Function namespace not found: %s", functionName.getCatalogSchemaName()));
        }
        checkFieldLength("Function name", functionName.getObjectName(), MAX_FUNCTION_NAME_LENGTH);

        if (function.getParameters().size() > MAX_PARAMETER_COUNT) {
            throw new PrestoException(GENERIC_USER_ERROR, format("Function has more than %s parameters: %s", MAX_PARAMETER_COUNT, function.getParameters().size()));
        }
        for (Parameter parameter : function.getParameters()) {
            checkFieldLength("Parameter name", parameter.getName(), MAX_PARAMETER_NAME_LENGTH);
        }

        checkFieldLength(
                "Parameter type list",
                function.getFunctionId().getArgumentTypes().stream()
                        .map(TypeSignature::toString)
                        .collect(joining(",")),
                MAX_PARAMETER_TYPES_LENGTH);
        checkFieldLength("Return type", function.getSignature().getReturnType().toString(), MAX_RETURN_TYPE_LENGTH);

        jdbi.useTransaction(handle -> {
            FunctionNamespaceDao transactionDao = handle.attach(functionNamespaceDaoClass);
            Optional<SqlInvokedFunctionRecord> latestVersion = transactionDao.getLatestRecordForUpdate(hash(function.getFunctionId()), function.getFunctionId());
            if (!replace && latestVersion.isPresent() && !latestVersion.orElseThrow().isDeleted()) {
                throw new PrestoException(ALREADY_EXISTS, "Function already exists: " + function.getFunctionId());

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Reduce the number of parameters by grouping them into a ROW type or map parameter.
  2. Split the function into multiple narrower functions/overloads.
  3. If the limit is genuinely too low for a legitimate use, increase MAX_PARAMETER_COUNT in the source and redeploy.
  4. Reformulate the SQL function to take fewer, richer arguments.

Example fix

// before
CREATE FUNCTION f(a1 bigint, ..., a200 bigint) ...
// after
CREATE FUNCTION f(inputs row(a1 bigint, ..., a200 bigint)) ...
Defensive patterns

Strategy: validation

Validate before calling

if (function.getParameters().size() > MAX_PARAMETER_COUNT) {
    throw new IllegalArgumentException("too many parameters: " + function.getParameters().size());
}

Prevention

When it happens

Trigger: Calling createFunction with function.getParameters().size() > MAX_PARAMETER_COUNT.

Common situations: Code-generated SQL functions with very long parameter lists; bulk-generating overloads; porting a function from a system without a parameter limit.

Related errors


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