prestodb/presto · error · RuntimeException
Unknown object inspector category:
Error message
Unknown object inspector category:
What it means
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.
Source
Thrown at presto-hive/src/main/java/com/facebook/presto/hive/util/SerDeUtils.java:101
}
// This version supports optionally disabling the filtering of null map key, which should only be used for building test data sets
// that contain null map keys. For production, null map keys are not allowed.
@VisibleForTesting
public static Block serializeObject(Type type, BlockBuilder builder, Object object, ObjectInspector inspector, boolean filterNullMapKeys, DateTimeZone hiveStorageTimeZone, boolean legacyTimestampEnabled)
{
switch (inspector.getCategory()) {
case PRIMITIVE:
serializePrimitive(type, builder, object, (PrimitiveObjectInspector) inspector, hiveStorageTimeZone, legacyTimestampEnabled);
return null;
case LIST:
return serializeList(type, builder, object, (ListObjectInspector) inspector, hiveStorageTimeZone, legacyTimestampEnabled);
case MAP:
return serializeMap(type, builder, object, (MapObjectInspector) inspector, filterNullMapKeys, hiveStorageTimeZone, legacyTimestampEnabled);
case STRUCT:
return serializeStruct(type, builder, object, (StructObjectInspector) inspector, hiveStorageTimeZone, legacyTimestampEnabled);
}
throw new RuntimeException("Unknown object inspector category: " + inspector.getCategory());
}
private static void serializePrimitive(Type type, BlockBuilder builder, Object object, PrimitiveObjectInspector inspector, DateTimeZone hiveStorageTimeZone, boolean legacyTimestampEnabled)
{
requireNonNull(builder, "parent builder is null");
if (object == null) {
builder.appendNull();
return;
}
switch (inspector.getPrimitiveCategory()) {
case BOOLEAN:
BooleanType.BOOLEAN.writeBoolean(builder, ((BooleanObjectInspector) inspector).get(object));
return;
case BYTE:
TinyintType.TINYINT.writeLong(builder, ((ByteObjectInspector) inspector).get(object));
return;View on GitHub (pinned to 55bb57d202)
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
Example fix
// before (Hive) CREATE TABLE t (u uniontype<int,string>); // after CREATE TABLE t (u string); -- or struct<a:int,b:string>
Defensive patterns
Strategy: type-guard
Validate before calling
// verify category is supported before serializing
ObjectInspector.Category c = inspector.getCategory();
if (c != Category.PRIMITIVE && c != Category.LIST && c != Category.MAP && c != Category.STRUCT) {
throw new PrestoException(NOT_SUPPORTED, "Unsupported inspector category: " + c);
} Type guard
boolean isSupportedCategory(ObjectInspector inspector) {
switch (inspector.getCategory()) {
case PRIMITIVE: case LIST: case MAP: case STRUCT: return true;
default: return false;
}
} Try / catch
try {
block = SerDeUtils.serializeObject(...);
} catch (RuntimeException e) {
if (e.getMessage() != null && e.getMessage().startsWith("Unknown object inspector category")) {
LOG.error("Column uses unsupported Hive type (e.g. uniontype): " + e.getMessage());
}
throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Hive tables containing uniontype columns; SerDe returning exotic inspectors for certain formats; schema drift after altering a column to a union type.
Related errors
- Unknown primitive type:
- Unexpected column type
- unsupported string field type:
- Unsupported column type:
- unknown java type
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/be2040ef4499578f.
Report an issue: GitHub.