{"record":{"id":"be2040ef4499578f","repo":"prestodb/presto","slug":"unknown-object-inspector-category","errorCode":null,"errorMessage":"Unknown object inspector category: ","messagePattern":"Unknown object inspector category: ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"presto-hive/src/main/java/com/facebook/presto/hive/util/SerDeUtils.java","lineNumber":101,"sourceCode":"    }\n\n    // This version supports optionally disabling the filtering of null map key, which should only be used for building test data sets\n    // that contain null map keys.  For production, null map keys are not allowed.\n    @VisibleForTesting\n    public static Block serializeObject(Type type, BlockBuilder builder, Object object, ObjectInspector inspector, boolean filterNullMapKeys, DateTimeZone hiveStorageTimeZone, boolean legacyTimestampEnabled)\n    {\n        switch (inspector.getCategory()) {\n            case PRIMITIVE:\n                serializePrimitive(type, builder, object, (PrimitiveObjectInspector) inspector, hiveStorageTimeZone, legacyTimestampEnabled);\n                return null;\n            case LIST:\n                return serializeList(type, builder, object, (ListObjectInspector) inspector, hiveStorageTimeZone, legacyTimestampEnabled);\n            case MAP:\n                return serializeMap(type, builder, object, (MapObjectInspector) inspector, filterNullMapKeys, hiveStorageTimeZone, legacyTimestampEnabled);\n            case STRUCT:\n                return serializeStruct(type, builder, object, (StructObjectInspector) inspector, hiveStorageTimeZone, legacyTimestampEnabled);\n        }\n        throw new RuntimeException(\"Unknown object inspector category: \" + inspector.getCategory());\n    }\n\n    private static void serializePrimitive(Type type, BlockBuilder builder, Object object, PrimitiveObjectInspector inspector, DateTimeZone hiveStorageTimeZone, boolean legacyTimestampEnabled)\n    {\n        requireNonNull(builder, \"parent builder is null\");\n\n        if (object == null) {\n            builder.appendNull();\n            return;\n        }\n\n        switch (inspector.getPrimitiveCategory()) {\n            case BOOLEAN:\n                BooleanType.BOOLEAN.writeBoolean(builder, ((BooleanObjectInspector) inspector).get(object));\n                return;\n            case BYTE:\n                TinyintType.TINYINT.writeLong(builder, ((ByteObjectInspector) inspector).get(object));\n                return;","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive/src/main/java/com/facebook/presto/hive/util/SerDeUtils.java#L83-L119","documentation":"SerDeUtils.serializeObject switches on the Hive ObjectInspector category (PRIMITIVE, LIST, MAP, STRUCT). If the inspector's category is anything else (e.g. UNION), there is no serialization branch and it throws RuntimeException('Unknown object inspector category: ...'). The serializer only supports the standard Hive column categories.","triggerScenarios":"Writing a Hive column whose ObjectInspector category is UNION or another non-standard category, recursively from serializeObject on a nested union field or a top-level union-typed column.","commonSituations":"Hive tables containing uniontype columns; SerDe returning exotic inspectors for certain formats; schema drift after altering a column to a union type.","solutions":["Remove or flatten uniontype columns (store as string/struct instead)","Cast the column in the Hive view/query to a supported type before Presto reads it","Recreate the table with a supported schema (no UNION types)","Check whether the SerDe is producing an unexpected inspector for a normal type and fix the table properties"],"exampleFix":"// before (Hive)\nCREATE TABLE t (u uniontype<int,string>);\n// after\nCREATE TABLE t (u string); -- or struct<a:int,b:string>","handlingStrategy":"type-guard","validationCode":"// verify category is supported before serializing\nObjectInspector.Category c = inspector.getCategory();\nif (c != Category.PRIMITIVE && c != Category.LIST && c != Category.MAP && c != Category.STRUCT) {\n    throw new PrestoException(NOT_SUPPORTED, \"Unsupported inspector category: \" + c);\n}","typeGuard":"boolean isSupportedCategory(ObjectInspector inspector) {\n    switch (inspector.getCategory()) {\n        case PRIMITIVE: case LIST: case MAP: case STRUCT: return true;\n        default: return false;\n    }\n}","tryCatchPattern":"try {\n    block = SerDeUtils.serializeObject(...);\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Unknown object inspector category\")) {\n        LOG.error(\"Column uses unsupported Hive type (e.g. uniontype): \" + e.getMessage());\n    }\n    throw e;\n}","preventionTips":["Avoid uniontype columns in Hive tables read by Presto","Audit table schemas with DESCRIBE to spot unsupported types early","Fix SerDe/table properties that yield exotic ObjectInspectors","Recreate tables using primitive/list/map/struct types only"],"tags":["hive","serde","object-inspector","unsupported-type"],"backgroundTag":"unsupported-object-inspector-category","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"}