prestodb/presto · error · IllegalArgumentException
Unsupported flat map key type:
Error message
Unsupported flat map key type:
What it means
MapFlatBatchStreamReader.getKeyBlockTemplate builds a Block template for the flat map's key column based on the key's ORC type. Only LONG and STRING/BINARY keys are supported; any other keyOrcType (e.g. DOUBLE, TIMESTAMP, DECIMAL) hits the default branch and throws IllegalArgumentException('Unsupported flat map key type: ' + keyOrcType). DWRF flat map storage only defines inlined key storage for those types.
Source
Thrown at presto-orc/src/main/java/com/facebook/presto/orc/reader/MapFlatBatchStreamReader.java:285
presentStream = null;
rowGroupOpen = false;
}
private Block getKeyBlockTemplate(Collection<DwrfSequenceEncoding> sequenceEncodings)
{
switch (keyOrcType) {
case BYTE:
case SHORT:
case INT:
case LONG:
return getIntegerKeyBlockTemplate(sequenceEncodings);
case STRING:
case BINARY:
return getSliceKeysBlockTemplate(sequenceEncodings);
default:
throw new IllegalArgumentException("Unsupported flat map key type: " + keyOrcType);
}
}
private Block getIntegerKeyBlockTemplate(Collection<DwrfSequenceEncoding> sequenceEncodings)
{
Type keyType;
switch (keyOrcType) {
case BYTE:
keyType = TinyintType.TINYINT;
break;
case SHORT:
keyType = SmallintType.SMALLINT;
break;
case INT:
keyType = IntegerType.INTEGER;
break;
case LONG:View on GitHub (pinned to 55bb57d202)
Solutions
- Inspect the flat map's key type in the DWRF footer to confirm which type is used.
- Upgrade Presto to a version supporting the key type (newer versions added more key templates).
- Re-write the data as a regular MAP column (MAP_DIRECT encoding) instead of flat map.
- Convert the map keys to STRING on the writer side so the STRING/BINARY template is used.
Example fix
// before — flat map keyed by DOUBLE
{"flatMap": {1.5: "a"}}
// after — cast keys to STRING on write
{"flatMap": {"1.5": "a"}} Defensive patterns
Strategy: validation
Validate before calling
OrcType keyOrcType = dwrfType.getKeyType();
if (!(keyOrcType.getOrcTypeKind() == LONG || keyOrcType.getOrcTypeKind() == STRING || keyOrcType.getOrcTypeKind() == BINARY)) {
throw new PrestoException(NOT_SUPPORTED, "Flat map key type " + keyOrcType + " unsupported; rewrite as MAP");
} Type guard
boolean isSupportedFlatMapKeyType(OrcTypeKind kind) {
return kind == LONG || kind == STRING || kind == BINARY;
} Try / catch
try {
reader.startStripe(timezone, stripe);
}
catch (IllegalArgumentException e) {
throw new PrestoException(NOT_SUPPORTED, "Flat map key type not supported: " + e.getMessage(), e);
} Prevention
- Check flat map key types in DWRF footers before ingesting files.
- Only use LONG/STRING/BINARY keys when writing flat maps.
- Fall back to standard MAP encoding for exotic key types.
- Upgrade Presto for newer flat-map key template support.
When it happens
Trigger: startStripe on a DWRF FLAT_MAP column whose key type is not LONG, STRING, or BINARY — e.g. flat maps keyed by double/decimal/timestamp written by DWRF tooling.
Common situations: Reading DWRF files that use extended flat-map key types unsupported by the current Presto version; writer/tooling emitting flat maps with non-standard key types; cross-version file interchange.
Related errors
- Unsupported flat map key type:
- Flat map reader does not support nesting
- Unsupported encoding
- NOT_SUPPORTED
- NOT_SUPPORTED
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/1b95b0813fe47f82.
Report an issue: GitHub.