{"record":{"id":"c9676cb5f3eefea7","repo":"prestodb/presto","slug":"expected-exactly-one-parameter-for-varchar","errorCode":null,"errorMessage":"Expected exactly one parameter for VARCHAR","messagePattern":"Expected exactly one parameter for VARCHAR","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/type/VarcharParametricType.java","lineNumber":44,"sourceCode":"public class VarcharParametricType\n        implements ParametricType\n{\n    public static final VarcharParametricType VARCHAR = new VarcharParametricType();\n\n    @Override\n    public String getName()\n    {\n        return StandardTypes.VARCHAR;\n    }\n\n    @Override\n    public Type createType(List<TypeParameter> parameters)\n    {\n        if (parameters.isEmpty()) {\n            return createUnboundedVarcharType();\n        }\n        if (parameters.size() != 1) {\n            throw new IllegalArgumentException(\"Expected exactly one parameter for VARCHAR\");\n        }\n\n        TypeParameter parameter = parameters.get(0);\n\n        if (!parameter.isLongLiteral()) {\n            throw new IllegalArgumentException(\"VARCHAR length must be a number\");\n        }\n\n        long length = parameter.getLongLiteral();\n\n        if (length == VarcharType.UNBOUNDED_LENGTH) {\n            return VarcharType.createUnboundedVarcharType();\n        }\n\n        if (length < 0 || length > VarcharType.MAX_LENGTH) {\n            throw new IllegalArgumentException(\"Invalid VARCHAR length \" + length);\n        }\n","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/type/VarcharParametricType.java#L26-L62","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","solutions":["Fix the type signature to use VARCHAR(n) with exactly one parameter, or plain VARCHAR for unbounded.","Search the connector/plugin metadata or DDL generator emitting the signature and correct the string formatting.","Validate signature strings in tests before registering custom types."],"exampleFix":"// before\nTypeSignature sig = parseSignature(\"VARCHAR(10, 20)\");\n// after\nTypeSignature sig = parseSignature(\"VARCHAR(10)\");","handlingStrategy":"validation","validationCode":"boolean isValidVarcharSignature(List<TypeParameter> params) {\n    return params.isEmpty() || params.size() == 1;\n}","typeGuard":null,"tryCatchPattern":"try {\n    Type t = typeManager.getType(parseSignature(sigString));\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"Expected exactly one parameter for VARCHAR\")) {\n        // fall back to unbounded VARCHAR\n    }\n}","preventionTips":["Never write VARCHAR with more than one parameter; use VARCHAR or VARCHAR(n).","Unit-test connector type-signature strings before registration.","Validate generated DDL with a schema linter."],"tags":["presto","varchar","type-system","illegal-argument","ddl"],"backgroundTag":"invalid-type-parameter-count","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"}