{"record":{"id":"eeae54dfb3b0b0b4","repo":"prestodb/presto","slug":"expected-0-1-or-2-parameters-for-decimal-type-con","errorCode":null,"errorMessage":"Expected 0, 1 or 2 parameters for DECIMAL type constructor.","messagePattern":"Expected 0, 1 or 2 parameters for DECIMAL type constructor\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/type/DecimalParametricType.java","lineNumber":51,"sourceCode":"    @Override\n    public String getName()\n    {\n        return StandardTypes.DECIMAL;\n    }\n\n    @Override\n    public Type createType(List<TypeParameter> parameters)\n    {\n        try {\n            switch (parameters.size()) {\n                case 0:\n                    return DecimalType.createDecimalType();\n                case 1:\n                    return DecimalType.createDecimalType(parameters.get(0).getLongLiteral().intValue());\n                case 2:\n                    return DecimalType.createDecimalType(parameters.get(0).getLongLiteral().intValue(), parameters.get(1).getLongLiteral().intValue());\n                default:\n                    throw new IllegalArgumentException(\"Expected 0, 1 or 2 parameters for DECIMAL type constructor.\");\n            }\n        }\n        catch (InvalidFunctionArgumentException e) {\n            throw new PrestoException(INVALID_FUNCTION_ARGUMENT, e.getMessage(), e);\n        }\n    }\n}\n","sourceCodeStart":33,"sourceCodeEnd":59,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/type/DecimalParametricType.java#L33-L59","documentation":"DecimalParametricType.createType only accepts 0, 1, or 2 parameters for DECIMAL; declaring the type with 3+ parameters (or otherwise reaching the default branch) throws IllegalArgumentException('Expected 0, 1 or 2 parameters for DECIMAL type constructor.'). Note this IAE is NOT converted to a PrestoException — only InvalidFunctionArgumentException is.","triggerScenarios":"DDL/statements like `CREATE TABLE t (x DECIMAL(10,2,3))`, `CAST(v AS DECIMAL(1,2,3))`, or a connector supplying more than two type parameters to DECIMAL.","commonSituations":"Hand-written DDL typos; programmatically built type signatures passing extra args; connectors/templates that concatenate parameter lists incorrectly.","solutions":["Remove extra parameters: use DECIMAL, DECIMAL(p), or DECIMAL(p,s) forms only","Fix the code that generates the type string to cap at 2 parameters","Catch/pre-validate the parameter count before invoking the type constructor"],"exampleFix":"// before\nCREATE TABLE t (x DECIMAL(10,2,0));\n// after\nCREATE TABLE t (x DECIMAL(10,2));","handlingStrategy":"validation","validationCode":"if (parameters != null && parameters.size() > 2) { throw new IllegalArgumentException(\"DECIMAL accepts at most 2 parameters\"); }","typeGuard":"boolean isValidDecimalSignature(int paramCount) { return paramCount >= 0 && paramCount <= 2; }","tryCatchPattern":"try { type = DecimalParametricType.createType(symbols); } catch (IllegalArgumentException e) { type = DecimalType.createDecimalType(); /* or surface to user */ }","preventionTips":["Only write DECIMAL, DECIMAL(p), DECIMAL(p,s) in DDL","Validate generated type strings in connectors before registration","Lint migration scripts for extra type parameters","Add tests for type-signature parsing"],"tags":["presto","decimal","type-constructor","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"}