prestodb/presto · error · RuntimeException
Unknown primitive type:
Error message
Unknown primitive type:
What it means
SerDeUtils.serializePrimitive switches over Hive primitive object inspector categories (boolean, byte, short, int, long, float, double, string, varchar, char, date, timestamp, decimal, binary...). A primitive category with no case in the switch falls through to a RuntimeException('Unknown primitive type: ...'). A new or exotic Hive primitive is not handled by this serializer.
Source
Thrown at presto-hive/src/main/java/com/facebook/presto/hive/util/SerDeUtils.java:166
return;
case TIMESTAMP:
TimestampType.TIMESTAMP.writeLong(builder, formatTimestampAsLong(object, (TimestampObjectInspector) inspector, hiveStorageTimeZone, legacyTimestampEnabled));
return;
case BINARY:
VARBINARY.writeSlice(builder, Slices.wrappedBuffer(((BinaryObjectInspector) inspector).getPrimitiveJavaObject(object)));
return;
case DECIMAL:
DecimalType decimalType = (DecimalType) type;
HiveDecimalWritable hiveDecimal = ((HiveDecimalObjectInspector) inspector).getPrimitiveWritableObject(object);
if (decimalType.isShort()) {
decimalType.writeLong(builder, DecimalUtils.getShortDecimalValue(hiveDecimal, decimalType.getScale()));
}
else {
decimalType.writeSlice(builder, DecimalUtils.getLongDecimalValue(hiveDecimal, decimalType.getScale()));
}
return;
}
throw new RuntimeException("Unknown primitive type: " + inspector.getPrimitiveCategory());
}
private static Block serializeList(Type type, BlockBuilder builder, Object object, ListObjectInspector inspector, DateTimeZone hiveStorageTimeZone, boolean legacyTimestampEnabled)
{
List<?> list = inspector.getList(object);
if (list == null) {
requireNonNull(builder, "parent builder is null").appendNull();
return null;
}
List<Type> typeParameters = type.getTypeParameters();
checkArgument(typeParameters.size() == 1, "list must have exactly 1 type parameter");
Type elementType = typeParameters.get(0);
ObjectInspector elementInspector = inspector.getListElementObjectInspector();
BlockBuilder currentBuilder;
if (builder != null) {
currentBuilder = builder.beginBlockEntry();
}View on GitHub (pinned to 55bb57d202)
Solutions
- Identify the primitive category printed in the message and check which table/column produces it
- Fix the table schema to use standard Hive primitives (e.g. replace void columns)
- Upgrade Presto to a version handling that primitive category
- Patch/extend serializePrimitive if you maintain a fork and the type is legitimate
Example fix
// before -- column shows up as void/unknown primitive in metastore // after ALTER TABLE t REPLACE COLUMNS (col string); -- use a supported primitive type
Defensive patterns
Strategy: type-guard
Validate before calling
// verify the primitive category is handled before serializing
PrimitiveObjectInspector.PrimitiveCategory pc = inspector.getPrimitiveCategory();
Set<PrimitiveCategory> supported = EnumSet.of(BOOLEAN, BYTE, SHORT, INT, LONG, FLOAT, DOUBLE,
STRING, VARCHAR, CHAR, DATE, TIMESTAMP, DECIMAL, BINARY);
if (!supported.contains(pc)) {
throw new PrestoException(NOT_SUPPORTED, "Unsupported primitive: " + pc);
} Type guard
boolean isSupportedPrimitive(PrimitiveObjectInspector inspector) {
return inspector.getPrimitiveCategory() != PrimitiveCategory.UNKNOWN
&& inspector.getPrimitiveCategory() != PrimitiveCategory.VOID;
} Try / catch
try {
block = SerDeUtils.serializeObject(...);
} catch (RuntimeException e) {
if (e.getMessage() != null && e.getMessage().startsWith("Unknown primitive type")) {
LOG.error("Unhandled Hive primitive: " + e.getMessage());
}
throw e;
} Prevention
- Check DESCRIBE output for void/odd primitives before querying
- Fix corrupt schema metadata (e.g. void columns) at the metastore
- Keep Hive and Presto versions aligned on primitive type support
- Extend serializePrimitive and add a test when introducing a new primitive category
When it happens
Trigger: serializeObject dispatches a PRIMITIVE inspector whose PrimitiveObjectInspector.PrimitiveCategory lacks a case branch in serializePrimitive — e.g. hive void/unknown or a newer Hive primitive added by the SerDe.
Common situations: Reading tables with unusual primitive columns (e.g. void from corrupt schema); SerDe/third-party storage handler returning a novel primitive category; Hive version mismatch introducing new primitive types.
Related errors
- Unknown object inspector category:
- 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/2d10e412c847cc5e.
Report an issue: GitHub.