prestodb/presto · error · IllegalArgumentException
Unsupported flat map key type:
Error message
Unsupported flat map key type:
What it means
MapFlatSelectiveStreamReader creates the key block for flat-map (DWRF_MAP_FLAT) columns. Only INTEGER and LONG key kinds (and STRING/BINARY via getSliceKeysBlock) are supported; any other key ORC type kind throws IllegalArgumentException. This is a limitation of the selective flat-map reader's supported key types.
Source
Thrown at presto-orc/src/main/java/com/facebook/presto/orc/reader/MapFlatSelectiveStreamReader.java:711
return requiredLongKeys.isEmpty() || requiredLongKeys.contains(value.getKey().getIntKey());
}
return requiredStringKeys.isEmpty() || requiredStringKeys.contains(value.getKey().getBytesKey().toStringUtf8());
}
private Block getKeysBlock(List<DwrfSequenceEncoding> sequenceEncodings)
{
switch (keyOrcTypeKind) {
case BYTE:
case SHORT:
case INT:
case LONG:
return getIntegerKeysBlock(sequenceEncodings);
case STRING:
case BINARY:
return getSliceKeysBlock(sequenceEncodings);
default:
throw new IllegalArgumentException("Unsupported flat map key type: " + keyOrcTypeKind);
}
}
private Block getIntegerKeysBlock(List<DwrfSequenceEncoding> sequenceEncodings)
{
Type keyType;
switch (keyOrcTypeKind) {
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
- Use a flat-map key ORC type among INTEGER, LONG, STRING, or BINARY
- Re-encode the file with a supported key type
- Use the non-selective (batch) reader or a non-flat map encoding
- Verify the ORC/DWRF writer settings used to produce the file
Example fix
// before
throw new IllegalArgumentException("Unsupported flat map key type: " + keyOrcTypeKind);
// after
if (!SUPPORTED_FLAT_KEY_KINDS.contains(keyOrcTypeKind)) { throw new OrcCorruptionException(id, "Unsupported flat map key type: " + keyOrcTypeKind); } Defensive patterns
Strategy: validation
Validate before calling
Set<OrcTypeKind> ok = EnumSet.of(INTEGER, LONG, STRING, BINARY); if (!ok.contains(keyOrcTypeKind)) { throw new IllegalArgumentException("Unsupported flat map key: " + keyOrcTypeKind); } Type guard
boolean supportsFlatMapKey(OrcTypeKind t) { return t == INTEGER || t == LONG || t == STRING || t == BINARY; } Try / catch
try { reader = createReader(descriptor, ...); } catch (IllegalArgumentException e) { if (e.getMessage().contains("Unsupported flat map key")) { fallbackToBatchReader(descriptor); } else throw e; } Prevention
- Enforce supported key kinds (INT/LONG/STRING/BINARY) in writer configs
- Validate stripe encoding metadata before using selective readers
- Keep presto-orc updated for newly supported key kinds
- Test flat-map files produced by your writer against your reader version
When it happens
Trigger: Constructing MapFlatSelectiveStreamReader for a flat map column whose key type kind is not INTEGER, LONG, STRING, or BINARY (e.g., BYTE, SHORT, VARCHAR variants not mapped, FLOAT, structural kinds).
Common situations: Files written with flat map keys of uncommon types; writer/reader version skew; falling into the selective path for maps expected to have simple keys.
Related errors
- Unsupported flat map key type:
- Flat map reader does not support nesting
- Unsupported encoding
- HIVE_INVALID_METADATA
- Unsupported type:
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/c23453926396dbbc.
Report an issue: GitHub.