{"record":{"id":"e57b572380617a48","repo":"prestodb/presto","slug":"generic-user-error-e57b57","errorCode":"GENERIC_USER_ERROR","errorMessage":"invalid joda pattern '%s' passed as format hint for column '%s'","messagePattern":"invalid joda pattern '(.+?)' passed as format hint for column '(.+?)'","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-record-decoder/src/main/java/com/facebook/presto/decoder/json/CustomDateTimeJsonFieldDecoder.java","lineNumber":67,"sourceCode":"{\n    private static final Set<Type> SUPPORTED_TYPES = ImmutableSet.of(DATE, TIME, TIME_WITH_TIME_ZONE, TIMESTAMP, TIMESTAMP_WITH_TIME_ZONE);\n\n    private final DecoderColumnHandle columnHandle;\n    private final DateTimeFormatter formatter;\n\n    public CustomDateTimeJsonFieldDecoder(DecoderColumnHandle columnHandle)\n    {\n        this.columnHandle = requireNonNull(columnHandle, \"columnHandle is null\");\n        if (!SUPPORTED_TYPES.contains(columnHandle.getType())) {\n            throwUnsupportedColumnType(columnHandle);\n        }\n\n        checkArgument(columnHandle.getFormatHint() != null, \"format hint not defined for column '%s'\", columnHandle.getName());\n        try {\n            formatter = DateTimeFormat.forPattern(columnHandle.getFormatHint()).withLocale(Locale.ENGLISH).withZoneUTC();\n        }\n        catch (IllegalArgumentException e) {\n            throw new PrestoException(\n                    GENERIC_USER_ERROR,\n                    format(\"invalid joda pattern '%s' passed as format hint for column '%s'\", columnHandle.getFormatHint(), columnHandle.getName()));\n        }\n    }\n\n    @Override\n    public FieldValueProvider decode(JsonNode value)\n    {\n        return new CustomDateTimeJsonValueProvider(value, columnHandle, formatter);\n    }\n\n    public static class CustomDateTimeJsonValueProvider\n            extends AbstractDateTimeJsonValueProvider\n    {\n        private final DateTimeFormatter formatter;\n\n        public CustomDateTimeJsonValueProvider(JsonNode value, DecoderColumnHandle columnHandle, DateTimeFormatter formatter)\n        {","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-record-decoder/src/main/java/com/facebook/presto/decoder/json/CustomDateTimeJsonFieldDecoder.java#L49-L85","documentation":"CustomDateTimeJsonFieldDecoder's constructor requires a format hint and compiles it with Joda-Time's DateTimeFormat.forPattern. If the pattern string is not a valid Joda pattern, the IllegalArgumentException is converted to a PrestoException GENERIC_USER_ERROR with this message. It is a table-definition error caught at decoder construction time, before any data is read.","triggerScenarios":"format hint contains invalid Joda pattern letters (e.g. 'YYYY-MM-DD hh:mm:ss' misusing D vs d, or stray characters like unquoted 'T' or punctuation Joda treats as pattern letters); hint copied from a SimpleDateFormat or moment.js pattern incompatible with Joda syntax.","commonSituations":"Authors writing SQL-style 'YYYY-MM-DD HH24:MI:SS' formats; using 'DD' (day-of-year) instead of 'dd' (day-of-month); forgetting to quote literal text like 'T' or 'UTC' inside the pattern; porting patterns from other libraries (java.time mostly compatible, moment/chrony not).","solutions":["Correct the format hint to valid Joda-Time pattern syntax (yyyy, MM, dd, HH, mm, ss; quote literals with single quotes)","Test the pattern in isolation with DateTimeFormat.forPattern(...) before updating the table definition","Replace non-Joda tokens (e.g. 'HH24:MI:SS' -> 'HH:mm:ss', 'DD' -> 'dd')","Wrap literal text in the pattern in single quotes, e.g. \"yyyy-MM-dd'T'HH:mm:ss\""],"exampleFix":"// before\nformat hint: 'YYYY-MM-DD HH24:MI:SS'\n// after\nformat hint: 'yyyy-MM-dd HH:mm:ss'","handlingStrategy":"validation","validationCode":"boolean isValidJodaPattern(String pattern) {\n    try {\n        org.joda.time.format.DateTimeFormat.forPattern(pattern);\n        return true;\n    } catch (IllegalArgumentException e) {\n        return false;\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    CsvColumnDecoder d = new CsvColumnDecoder(columnHandles); // or json decoder construction\n} catch (PrestoException e) {\n    if (e.getErrorCode().getName().equals(\"GENERIC_USER_ERROR\") && e.getMessage().contains(\"invalid joda pattern\")) {\n        throw new TableConfigException(\"Fix format hint in table definition\", e);\n    }\n    throw e;\n}","preventionTips":["Validate format hints with DateTimeFormat.forPattern in CI before applying table DDL","Quote literal characters in patterns ('T', timezones) with single quotes","Use Joda docs tokens: yyyy MM dd HH mm ss — not SQL style HH24/MI/SS","Keep a tested library of approved patterns for common source formats"],"tags":["json","datetime","configuration","joda","format-pattern"],"backgroundTag":"invalid-datetime-format-pattern","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"}