apache/iceberg · error · UnsupportedOperationException
Cannot convert unknown primitive type
Error message
Cannot convert unknown primitive type: %s
What it means
Thrown by MessageTypeToType.primitive when converting a Parquet MessageType primitive column into an Iceberg Type and the primitive name matches no known case. Indicates the Parquet schema contains a primitive this Iceberg version cannot map.
Solutions
- Upgrade Iceberg so the primitive type is mapped
- Rewrite the data with supported Parquet primitive types
- Inspect the offending column with parquet-tools and adjust the schema
Example fix
// before // reading file with newer parquet type using old iceberg // after // upgrade dependency // implementation 'org.apache.iceberg:iceberg-spark-runtime:latest'
Defensive patterns
Strategy: try-catch
Validate before calling
MessageType parquetSchema = ParquetFileReader.readFooter(conf, path).getFileMetaData().getSchema();
parquetSchema.getColumns().forEach(c -> {
if (!KNOWN_PRIMITIVES.contains(c.getPrimitiveTypeName())) throw new IllegalStateException("Unmappable type: " + c.getPrimitiveTypeName());
}); Try / catch
try {
Type icebergType = new MessageTypeToType(parquetSchema).convert(field);
} catch (UnsupportedOperationException e) {
if (e.getMessage().startsWith("Cannot convert unknown primitive type")) { /* upgrade iceberg */ }
} Prevention
- Keep Iceberg up to date with the Parquet versions your writers emit
- Audit external Parquet data sources before registering them as tables
- Avoid mixed parquet-mr/iceberg library versions on the classpath
When it happens
Trigger: Converting a Parquet schema (MessageType) to an Iceberg Type where the column's primitive falls through the switch, e.g. a type added in newer Parquet releases.
Common situations: Reading files produced by newer writers than the Iceberg version in use; INT96 or other edge types before mapping existed; incompatible library versions on the classpath.
Understand the failure class
Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.
Related errors
- Avro writer does not support variant types
- Byte stream split encoding is not supported for type " +…
- Can't handle
- Cannot decode dictionary of type
- Not a boolean column
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/31c2949f0dd91433.
Report an issue: GitHub.
Appendix: source
Thrown at parquet/src/main/java/org/apache/iceberg/parquet/MessageTypeToType.java:181
case BOOLEAN:
return Types.BooleanType.get();
case INT32:
return Types.IntegerType.get();
case INT64:
return Types.LongType.get();
case FLOAT:
return Types.FloatType.get();
case DOUBLE:
return Types.DoubleType.get();
case FIXED_LEN_BYTE_ARRAY:
return Types.FixedType.ofLength(primitive.getTypeLength());
case INT96:
return Types.TimestampType.withZone();
case BINARY:
return Types.BinaryType.get();
}
throw new UnsupportedOperationException("Cannot convert unknown primitive type: " + primitive);
}
@Override
public Type variant(GroupType variant) {
return Types.VariantType.get();
}
private static class ParquetLogicalTypeVisitor
implements LogicalTypeAnnotation.LogicalTypeAnnotationVisitor<Type> {
private static final ParquetLogicalTypeVisitor INSTANCE = new ParquetLogicalTypeVisitor();
private static ParquetLogicalTypeVisitor get() {
return INSTANCE;
}
@Override
public Optional<Type> visit(LogicalTypeAnnotation.StringLogicalTypeAnnotation stringType) {
return Optional.of(Types.StringType.get());View on GitHub (pinned to 86d9c8fc54)