prestodb/presto · error · IllegalArgumentException

Expected at most one parameter for CHAR

Error message

Expected at most one parameter for CHAR

What it means

CharParametricType.createType throws this IllegalArgumentException when a CHAR type is declared with more than one type parameter (e.g. CHAR(5,2)). CHAR accepts at most one length parameter; zero parameters defaults to length 1. This is a type-definition/DLL error, not a data error.

Source

Thrown at presto-main-base/src/main/java/com/facebook/presto/type/CharParametricType.java:46

public class CharParametricType
        implements ParametricType
{
    public static final CharParametricType CHAR = new CharParametricType();

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

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

        TypeParameter parameter = parameters.get(0);

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

        try {
            return createCharType(parameter.getLongLiteral());
        }
        catch (InvalidFunctionArgumentException e) {
            throw new PrestoException(INVALID_FUNCTION_ARGUMENT, e.getMessage(), e);
        }
    }
}

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Use a single length parameter: CHAR(n).
  2. Use CHAR with no parameters if you want the default length 1.
  3. If porting DDL from another engine, remove extra parameters or map to the correct Presto type.

Example fix

// before
CREATE TABLE t (c CHAR(5, 2));
// after
CREATE TABLE t (c CHAR(5));
Defensive patterns

Strategy: validation

Validate before calling

// validate DDL/type signature before registering
if (typeParameters.size() > 1) throw new IllegalArgumentException("CHAR accepts at most one length parameter");

Type guard

boolean isValidCharSignature(List<TypeParameter> ps) { return ps.size() <= 1; }

Try / catch

try { Type t = charParametricType.createType(params); } catch (IllegalArgumentException e) { /* fix signature arity and retry */ }

Prevention

When it happens

Trigger: Registering or parsing a type signature like CHAR(a,b), or programmatic TypeSignature construction passing multiple parameters to CHAR.

Common situations: Hand-written DDL copied from other engines (e.g. DECIMAL-style CHAR(p,s)), or connectors building type signatures dynamically with wrong arity.

Related errors


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