{"record":{"id":"2374f6793d34a89b","repo":"prestodb/presto","slug":"unexpected-decimal-literal-text","errorCode":null,"errorMessage":"Unexpected decimal literal: ${text}","messagePattern":"Unexpected decimal literal: (.+?)","errorType":"exception","errorClass":"ParsingException","httpStatus":null,"severity":"error","filePath":"presto-parser/src/main/java/com/facebook/presto/sql/parser/AstBuilder.java","lineNumber":2541,"sourceCode":"        return new GenericLiteral(getLocation(context), type, value);\n    }\n\n    @Override\n    public Node visitIntegerLiteral(SqlBaseParser.IntegerLiteralContext context)\n    {\n        return new LongLiteral(getLocation(context), context.getText());\n    }\n\n    @Override\n    public Node visitDecimalLiteral(SqlBaseParser.DecimalLiteralContext context)\n    {\n        switch (parsingOptions.getDecimalLiteralTreatment()) {\n            case AS_DOUBLE:\n                return new DoubleLiteral(getLocation(context), context.getText());\n            case AS_DECIMAL:\n                return new DecimalLiteral(getLocation(context), context.getText());\n            case REJECT:\n                throw new ParsingException(\"Unexpected decimal literal: \" + context.getText());\n        }\n        throw new AssertionError(\"Unreachable\");\n    }\n\n    @Override\n    public Node visitDoubleLiteral(SqlBaseParser.DoubleLiteralContext context)\n    {\n        return new DoubleLiteral(getLocation(context), context.getText());\n    }\n\n    @Override\n    public Node visitBooleanValue(SqlBaseParser.BooleanValueContext context)\n    {\n        return new BooleanLiteral(getLocation(context), context.getText());\n    }\n\n    @Override\n    public Node visitInterval(SqlBaseParser.IntervalContext context)","sourceCodeStart":2523,"sourceCodeEnd":2559,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-parser/src/main/java/com/facebook/presto/sql/parser/AstBuilder.java#L2523-L2559","documentation":"AstBuilder.visitDecimalLiteral throws ParsingException when parsingOptions.getDecimalLiteralTreatment() is REJECT and the input contains a decimal literal (e.g. 1.23). The parser is configured to refuse decimal literals rather than coerce them to DOUBLE or DECIMAL.","triggerScenarios":"Calling SqlParser with ParsingOptions decimalLiteralTreatment=REJECT and parsing any statement containing a decimal number literal.","commonSituations":"Server/tooling code that explicitly sets REJECT to force legacy behavior, or API users who copied ParsingOptions.builder().decimalLiteralTreatment(DecimalLiteralTreatment.REJECT) from strict-mode examples.","solutions":["Change ParsingOptions to AS_DECIMAL so decimals become DecimalLiteral.","Or use AS_DOUBLE if legacy DoubleLiteral semantics are desired.","Rewrite the SQL to avoid decimal literals (e.g. CAST('1.23' AS DECIMAL)).","If the server sets REJECT, remove or reconfigure that option at the caller site."],"exampleFix":"// before\nnew SqlParser().createStatement(\"SELECT 1.5\", ParsingOptions.builder().decimalLiteralTreatment(DecimalLiteralTreatment.REJECT).build());\n// after\nnew SqlParser().createStatement(\"SELECT 1.5\", ParsingOptions.builder().decimalLiteralTreatment(DecimalLiteralTreatment.AS_DECIMAL).build());","handlingStrategy":"validation","validationCode":"// reject REJECT mode when SQL contains decimal literals\nif (parsingOptions.getDecimalLiteralTreatment() == DecimalLiteralTreatment.REJECT\n        && Pattern.compile(\"\\\\b\\\\d+\\\\.\\\\d+\\\\b\").matcher(sql).find()) {\n    throw new IllegalArgumentException(\"Decimal literal present but treatment is REJECT\");\n}","typeGuard":"boolean isDecimalLiteralRejected(ParsingOptions opts, String sql) {\n    return opts.getDecimalLiteralTreatment() == DecimalLiteralTreatment.REJECT\n        && Pattern.compile(\"\\\\d+\\\\.\\\\d+\").matcher(sql).find();\n}","tryCatchPattern":"try {\n    parser.createStatement(sql, parsingOptions);\n} catch (ParsingException e) {\n    if (e.getMessage().startsWith(\"Unexpected decimal literal\")) {\n        ParsingOptions relaxed = ParsingOptions.builder(parsingOptions)\n            .decimalLiteralTreatment(DecimalLiteralTreatment.AS_DECIMAL).build();\n        parser.createStatement(sql, relaxed);\n    } else throw e;\n}","preventionTips":["Use AS_DECIMAL (the modern default) unless legacy DOUBLE semantics are required.","Never copy REJECT-mode ParsingOptions from legacy examples without intent.","Strip or CAST decimal literals when strict parsing is mandatory."],"tags":["sql-parser","decimal-literal","parsing-options"],"backgroundTag":"unsupported-literal","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"}