prestodb/presto · error · IllegalArgumentException

Expected exactly one parameter for VARCHAR

Error message

Expected exactly one parameter for VARCHAR

What it means

VARCHAR in Presto is parametric: it takes either zero parameters (unbounded) or exactly one length parameter. This IllegalArgumentException is thrown at type-creation time when the type manager receives a VARCHAR type signature with two or more parameters, e.g. VARCHAR(10, 20).

Source

Thrown at presto-main-base/src/main/java/com/facebook/presto/type/VarcharParametricType.java:44

public class VarcharParametricType
        implements ParametricType
{
    public static final VarcharParametricType VARCHAR = new VarcharParametricType();

    @Override
    public String getName()
    {
        return StandardTypes.VARCHAR;
    }

    @Override
    public Type createType(List<TypeParameter> parameters)
    {
        if (parameters.isEmpty()) {
            return createUnboundedVarcharType();
        }
        if (parameters.size() != 1) {
            throw new IllegalArgumentException("Expected exactly one parameter for VARCHAR");
        }

        TypeParameter parameter = parameters.get(0);

        if (!parameter.isLongLiteral()) {
            throw new IllegalArgumentException("VARCHAR length must be a number");
        }

        long length = parameter.getLongLiteral();

        if (length == VarcharType.UNBOUNDED_LENGTH) {
            return VarcharType.createUnboundedVarcharType();
        }

        if (length < 0 || length > VarcharType.MAX_LENGTH) {
            throw new IllegalArgumentException("Invalid VARCHAR length " + length);
        }

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Fix the type signature to use VARCHAR(n) with exactly one parameter, or plain VARCHAR for unbounded.
  2. Search the connector/plugin metadata or DDL generator emitting the signature and correct the string formatting.
  3. Validate signature strings in tests before registering custom types.

Example fix

// before
TypeSignature sig = parseSignature("VARCHAR(10, 20)");
// after
TypeSignature sig = parseSignature("VARCHAR(10)");
Defensive patterns

Strategy: validation

Validate before calling

boolean isValidVarcharSignature(List<TypeParameter> params) {
    return params.isEmpty() || params.size() == 1;
}

Try / catch

try {
    Type t = typeManager.getType(parseSignature(sigString));
} catch (IllegalArgumentException e) {
    if (e.getMessage().contains("Expected exactly one parameter for VARCHAR")) {
        // fall back to unbounded VARCHAR
    }
}

Prevention

When it happens

Trigger: Registering or resolving a type signature like VARCHAR(a, b) — more than one type parameter supplied to VARCHAR in DDL, a connector/plugin TypeSignature, or a serialized plan referencing a malformed VARCHAR signature.

Common situations: Hand-written connector metadata with a wrong type signature string, code-generated DDL, query rewrite tools that duplicate parameters, plugin version mismatches producing malformed signatures.

Related errors


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