{"record":{"id":"9f10548ad596abfc","repo":"prestodb/presto","slug":"invalid-literal-9f1054","errorCode":"INVALID_LITERAL","errorMessage":"'%s' is not a valid timestamp literal","messagePattern":"'(.+?)' is not a valid timestamp literal","errorType":"error_code","errorClass":"SemanticException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/sql/planner/LiteralInterpreter.java","lineNumber":300,"sourceCode":"                return parseTimeLiteral(node.getValue());\n            }\n        }\n\n        @Override\n        protected Long visitTimestampLiteral(TimestampLiteral node, ConnectorSession session)\n        {\n            SqlFunctionProperties properties = session.getSqlFunctionProperties();\n\n            try {\n                if (properties.isLegacyTimestamp()) {\n                    return parseTimestampLiteral(properties.getTimeZoneKey(), node.getValue());\n                }\n                else {\n                    return parseTimestampLiteral(node.getValue());\n                }\n            }\n            catch (RuntimeException e) {\n                throw new SemanticException(INVALID_LITERAL, node, \"'%s' is not a valid timestamp literal\", node.getValue());\n            }\n        }\n\n        @Override\n        protected Long visitIntervalLiteral(IntervalLiteral node, ConnectorSession session)\n        {\n            if (node.isYearToMonth()) {\n                return node.getSign().multiplier() * parseYearMonthInterval(node.getValue(), node.getStartField(), node.getEndField());\n            }\n            else {\n                return node.getSign().multiplier() * parseDayTimeInterval(node.getValue(), node.getStartField(), node.getEndField());\n            }\n        }\n\n        @Override\n        protected Object visitNullLiteral(NullLiteral node, ConnectorSession session)\n        {\n            return null;","sourceCodeStart":282,"sourceCodeEnd":318,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/sql/planner/LiteralInterpreter.java#L282-L318","documentation":"Literal interpretation error: the text of a timestamp literal could not be parsed by Presto's timestamp parser in either legacy-timestamp (time-zone-aware) or default mode. The %s is the literal text as written in the query; the faulty input is the TIMESTAMP '...' literal itself.","triggerScenarios":"Evaluating TIMESTAMP '<text>' where parseTimestampLiteral (or legacy path) throws at runtime — bad format, invalid dates like month 13, missing components.","commonSituations":"Copy-pasted dates with wrong separators, ambiguous formats (legacy vs new timestamp parsing), locale assumptions, out-of-range values.","solutions":["Correct the literal to ISO 8601 format: TIMESTAMP 'YYYY-MM-DD HH:MM:SS[.fff]'.","Verify the date components are valid and in range.","Check legacy timestamp session property if parsing differs between environments."],"exampleFix":"// before\nSELECT TIMESTAMP '2026/13/45';\n// after\nSELECT TIMESTAMP '2026-01-01 12:00:00';","handlingStrategy":"validation","validationCode":"try { java.time.LocalDateTime.parse(text, DateTimeFormatter.ofPattern(\"yyyy-MM-dd HH:mm:ss[.SSS]\")); } catch (DateTimeParseException e) { /* invalid TIMESTAMP literal text */ }","typeGuard":"boolean isValidTimestampText(String text) { try { java.time.LocalDateTime.parse(text.replace('T', ' '), DateTimeFormatter.ofPattern(\"yyyy-MM-dd HH:mm:ss[.SSS]\")); return true; } catch (DateTimeParseException e) { return false; } }","tryCatchPattern":"try { return visitTimestampLiteral(node, session); } catch (SemanticException e) { if (e.getCode() == INVALID_LITERAL) { /* surface message with the offending text */ } else { throw e; } }","preventionTips":["Write TIMESTAMP literals in ISO 8601: 'YYYY-MM-DD HH:MM:SS[.fff]'","Validate date components (month 1-12, day valid for month) before submitting","Watch out for legacy vs new timestamp parsing differences between sessions"],"tags":["literal","timestamp","parse-error"],"backgroundTag":"invalid-literal-format","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"}