prestodb/presto · error · IllegalArgumentException
Invalid mapping for column '%s'
Error message
Invalid mapping for column '%s'
What it means
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>'.
Source
Thrown at presto-kafka/src/main/java/com/facebook/presto/kafka/encoder/raw/RawRowEncoder.java:142
private final String name;
private final Type type;
private final FieldType fieldType;
private final int start;
private final int end;
public ColumnMapping(EncoderColumnHandle columnHandle)
{
this.name = columnHandle.getName();
this.type = columnHandle.getType();
this.fieldType = parseFieldType(columnHandle.getDataFormat(), this.name);
checkFieldType(this.name, this.type, this.fieldType);
Optional<String> mapping = Optional.ofNullable(columnHandle.getMapping());
if (mapping.isPresent()) {
Matcher mappingMatcher = MAPPING_PATTERN.matcher(mapping.get());
if (!mappingMatcher.matches()) {
throw new IllegalArgumentException(format("Invalid mapping for column '%s'", this.name));
}
if (mappingMatcher.group(2) != null) {
this.start = parseOffset(mappingMatcher.group(1), "start", this.name);
this.end = parseOffset(mappingMatcher.group(2), "end", this.name);
}
else {
this.start = parseOffset(mappingMatcher.group(1), "start", this.name);
this.end = this.start + this.fieldType.getSize();
}
}
else {
throw new IllegalArgumentException(format("No mapping defined for column '%s'", this.name));
}
}
private static int parseOffset(String group, String offsetName, String columnName)
{View on GitHub (pinned to 55bb57d202)
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.
Example fix
// before "mapping": "bytes:LONG" // after "mapping": "0-7"
Defensive patterns
Strategy: validation
Validate before calling
// mapping must look like '<start>-<end>' or '<dataFormat>:<fieldType>'
java.util.regex.Pattern p = java.util.regex.Pattern.compile("...MAPPING_PATTERN...");
if (mapping != null && !p.matcher(mapping).matches()) {
throw new IllegalArgumentException("Bad mapping: " + mapping);
}
Try / catch
try {
createKafkaTable(defn);
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("Invalid mapping")) {
// surface the offending column and fix its mapping syntax
}
throw e;
} Prevention
- 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.
When it happens
Trigger: 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'.
Common situations: 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.
Related errors
- Mapping length '%s' is not equal to expected length '%s' for
- No mapping defined for column '%s'
- Unable to parse '%s' offset for column '%s'
- unexpected internal column '%s'
- Column '%s' does not support 'null' value
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/822c3e542d803300.
Report an issue: GitHub.