{"record":{"id":"ad04f280e97bbdb6","repo":"prestodb/presto","slug":"expected-at-most-one-parameter-for-char","errorCode":null,"errorMessage":"Expected at most one parameter for CHAR","messagePattern":"Expected at most one parameter for CHAR","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/type/CharParametricType.java","lineNumber":46,"sourceCode":"public class CharParametricType\n        implements ParametricType\n{\n    public static final CharParametricType CHAR = new CharParametricType();\n\n    @Override\n    public String getName()\n    {\n        return StandardTypes.CHAR;\n    }\n\n    @Override\n    public Type createType(List<TypeParameter> parameters)\n    {\n        if (parameters.isEmpty()) {\n            return createCharType(1);\n        }\n        if (parameters.size() != 1) {\n            throw new IllegalArgumentException(\"Expected at most one parameter for CHAR\");\n        }\n\n        TypeParameter parameter = parameters.get(0);\n\n        if (!parameter.isLongLiteral()) {\n            throw new IllegalArgumentException(\"CHAR length must be a number\");\n        }\n\n        try {\n            return createCharType(parameter.getLongLiteral());\n        }\n        catch (InvalidFunctionArgumentException e) {\n            throw new PrestoException(INVALID_FUNCTION_ARGUMENT, e.getMessage(), e);\n        }\n    }\n}\n","sourceCodeStart":28,"sourceCodeEnd":63,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/type/CharParametricType.java#L28-L63","documentation":"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.","triggerScenarios":"Registering or parsing a type signature like CHAR(a,b), or programmatic TypeSignature construction passing multiple parameters to CHAR.","commonSituations":"Hand-written DDL copied from other engines (e.g. DECIMAL-style CHAR(p,s)), or connectors building type signatures dynamically with wrong arity.","solutions":["Use a single length parameter: CHAR(n).","Use CHAR with no parameters if you want the default length 1.","If porting DDL from another engine, remove extra parameters or map to the correct Presto type."],"exampleFix":"// before\nCREATE TABLE t (c CHAR(5, 2));\n// after\nCREATE TABLE t (c CHAR(5));","handlingStrategy":"validation","validationCode":"// validate DDL/type signature before registering\nif (typeParameters.size() > 1) throw new IllegalArgumentException(\"CHAR accepts at most one length parameter\");","typeGuard":"boolean isValidCharSignature(List<TypeParameter> ps) { return ps.size() <= 1; }","tryCatchPattern":"try { Type t = charParametricType.createType(params); } catch (IllegalArgumentException e) { /* fix signature arity and retry */ }","preventionTips":["Only ever pass zero or one parameter to CHAR.","Review DDL ported from other engines for multi-parameter types.","Add schema validation before registering custom signatures."],"tags":["presto","type-system","char","ddl"],"backgroundTag":"invalid-parameter-type","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}