{"record":{"id":"822c3e542d803300","repo":"prestodb/presto","slug":"invalid-mapping-for-column-s","errorCode":null,"errorMessage":"Invalid mapping for column '%s'","messagePattern":"Invalid mapping for column '(.+?)'","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-kafka/src/main/java/com/facebook/presto/kafka/encoder/raw/RawRowEncoder.java","lineNumber":142,"sourceCode":"        private final String name;\n        private final Type type;\n        private final FieldType fieldType;\n        private final int start;\n        private final int end;\n\n        public ColumnMapping(EncoderColumnHandle columnHandle)\n        {\n            this.name = columnHandle.getName();\n            this.type = columnHandle.getType();\n\n            this.fieldType = parseFieldType(columnHandle.getDataFormat(), this.name);\n            checkFieldType(this.name, this.type, this.fieldType);\n\n            Optional<String> mapping = Optional.ofNullable(columnHandle.getMapping());\n            if (mapping.isPresent()) {\n                Matcher mappingMatcher = MAPPING_PATTERN.matcher(mapping.get());\n                if (!mappingMatcher.matches()) {\n                    throw new IllegalArgumentException(format(\"Invalid mapping for column '%s'\", this.name));\n                }\n\n                if (mappingMatcher.group(2) != null) {\n                    this.start = parseOffset(mappingMatcher.group(1), \"start\", this.name);\n                    this.end = parseOffset(mappingMatcher.group(2), \"end\", this.name);\n                }\n                else {\n                    this.start = parseOffset(mappingMatcher.group(1), \"start\", this.name);\n                    this.end = this.start + this.fieldType.getSize();\n                }\n            }\n            else {\n                throw new IllegalArgumentException(format(\"No mapping defined for column '%s'\", this.name));\n            }\n        }\n\n        private static int parseOffset(String group, String offsetName, String columnName)\n        {","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-kafka/src/main/java/com/facebook/presto/kafka/encoder/raw/RawRowEncoder.java#L124-L160","documentation":"In RawRowEncoder's ColumnMapping constructor, a present mapping string that does not match MAPPING_PATTERN (an optional start-end integer range like '<start>-<end>' or a dataFormat:fieldType spec) causes an IllegalArgumentException 'Invalid mapping for column <name>'.","triggerScenarios":"A column's mapping property is set but its text does not match the accepted pattern, e.g. 'foo', '5-', '-7', 'abc:def:ghi', or non-numeric offsets like 'a-b'.","commonSituations":"Typo in the mapping syntax in the topic data table definition; using a named/keyword mapping (like 'key' or 'message') unsupported by this encoder; missing quotes causing parts of the mapping to be dropped from the JSON.","solutions":["Correct the mapping string to the expected format: either '<start>-<end>' byte offsets or '<dataFormat>:<fieldType>', e.g. '0-8'.","Remove the mapping property entirely if the intent was to omit it (which produces the clearer 'No mapping defined' error).","Validate the topic definition JSON so the mapping value reaches the encoder intact."],"exampleFix":"// before\n\"mapping\": \"bytes:LONG\"\n// after\n\"mapping\": \"0-7\"","handlingStrategy":"validation","validationCode":"// mapping must look like '<start>-<end>' or '<dataFormat>:<fieldType>'\njava.util.regex.Pattern p = java.util.regex.Pattern.compile(\"...MAPPING_PATTERN...\");\nif (mapping != null && !p.matcher(mapping).matches()) {\n    throw new IllegalArgumentException(\"Bad mapping: \" + mapping);\n}\n","typeGuard":null,"tryCatchPattern":"try {\n    createKafkaTable(defn);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Invalid mapping\")) {\n        // surface the offending column and fix its mapping syntax\n    }\n    throw e;\n}","preventionTips":["Check the exact regex accepted by this Presto version before writing mappings.","Quote mapping values in JSON so no characters are lost.","Test table creation against a dev cluster before production deploy."],"tags":["kafka","encoder","column-mapping","config"],"backgroundTag":"invalid-column-mapping","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"}