{"record":{"id":"1b95b0813fe47f82","repo":"prestodb/presto","slug":"unsupported-flat-map-key-type","errorCode":null,"errorMessage":"Unsupported flat map key type: ","messagePattern":"Unsupported flat map key type: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-orc/src/main/java/com/facebook/presto/orc/reader/MapFlatBatchStreamReader.java","lineNumber":285,"sourceCode":"\n        presentStream = null;\n\n        rowGroupOpen = false;\n    }\n\n    private Block getKeyBlockTemplate(Collection<DwrfSequenceEncoding> sequenceEncodings)\n    {\n        switch (keyOrcType) {\n            case BYTE:\n            case SHORT:\n            case INT:\n            case LONG:\n                return getIntegerKeyBlockTemplate(sequenceEncodings);\n            case STRING:\n            case BINARY:\n                return getSliceKeysBlockTemplate(sequenceEncodings);\n            default:\n                throw new IllegalArgumentException(\"Unsupported flat map key type: \" + keyOrcType);\n        }\n    }\n\n    private Block getIntegerKeyBlockTemplate(Collection<DwrfSequenceEncoding> sequenceEncodings)\n    {\n        Type keyType;\n\n        switch (keyOrcType) {\n            case BYTE:\n                keyType = TinyintType.TINYINT;\n                break;\n            case SHORT:\n                keyType = SmallintType.SMALLINT;\n                break;\n            case INT:\n                keyType = IntegerType.INTEGER;\n                break;\n            case LONG:","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-orc/src/main/java/com/facebook/presto/orc/reader/MapFlatBatchStreamReader.java#L267-L303","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before — flat map keyed by DOUBLE\n{\"flatMap\": {1.5: \"a\"}}\n// after — cast keys to STRING on write\n{\"flatMap\": {\"1.5\": \"a\"}}","handlingStrategy":"validation","validationCode":"OrcType keyOrcType = dwrfType.getKeyType();\nif (!(keyOrcType.getOrcTypeKind() == LONG || keyOrcType.getOrcTypeKind() == STRING || keyOrcType.getOrcTypeKind() == BINARY)) {\n    throw new PrestoException(NOT_SUPPORTED, \"Flat map key type \" + keyOrcType + \" unsupported; rewrite as MAP\");\n}","typeGuard":"boolean isSupportedFlatMapKeyType(OrcTypeKind kind) {\n    return kind == LONG || kind == STRING || kind == BINARY;\n}","tryCatchPattern":"try {\n    reader.startStripe(timezone, stripe);\n}\ncatch (IllegalArgumentException e) {\n    throw new PrestoException(NOT_SUPPORTED, \"Flat map key type not supported: \" + e.getMessage(), e);\n}","preventionTips":["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."],"tags":["dwrf","flat-map","unsupported-type"],"backgroundTag":"unsupported-encoding","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"}