apache/iceberg · error · IllegalArgumentException
Unsupported type:
Error message
Unsupported type:
What it means
SparkPlannedAvroReader.primitive() switches on the Avro primitive schema type (NULL, BOOLEAN, INT, LONG, FLOAT, DOUBLE, STRING, FIXED, BYTES, ENUM). Any Avro primitive not covered — such as RECORD or ARRAY appearing where a primitive is expected, or future Avro types — reaches the default branch and throws IllegalArgumentException with the schema. Reader construction fails for the file.
Source
Thrown at spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/data/SparkPlannedAvroReader.java:194
case LONG:
return ValueReaders.longs();
case FLOAT:
if (partner != null && partner.typeId() == Type.TypeID.DOUBLE) {
return ValueReaders.floatsAsDoubles();
}
return ValueReaders.floats();
case DOUBLE:
return ValueReaders.doubles();
case STRING:
return SparkValueReaders.strings();
case FIXED:
return ValueReaders.fixed(primitive.getFixedSize());
case BYTES:
return ValueReaders.bytes();
case ENUM:
return SparkValueReaders.enums(primitive.getEnumSymbols());
default:
throw new IllegalArgumentException("Unsupported type: " + primitive);
}
}
}
}
View on GitHub (pinned to 86d9c8fc54)
Solutions
- Print the Avro file schema and verify the field types; ensure nested types are handled by the reader factory, not primitive()
- Rewrite the data files with a schema that matches the Iceberg table schema
- Refresh/repair the table metadata so Iceberg's projected schema matches the files' Avro schema
- Upgrade Iceberg if a newly supported Avro type is involved
Defensive patterns
Strategy: validation
Validate before calling
for (Field f : avroSchema.getFields()) {
Schema.Type t = f.schema().getType();
if (!(t == Schema.Type.NULL || t == Schema.Type.BOOLEAN || t == Schema.Type.INT
|| t == Schema.Type.LONG || t == Schema.Type.FLOAT || t == Schema.Type.DOUBLE
|| t == Schema.Type.STRING || t == Schema.Type.FIXED || t == Schema.Type.BYTES
|| t == Schema.Type.ENUM)) {
throw new IllegalStateException("Unexpected Avro type at primitive level: " + t);
}
} Type guard
boolean isSupportedAvroPrimitive(Schema s) {
switch (s.getType()) {
case NULL: case BOOLEAN: case INT: case LONG: case FLOAT: case DOUBLE:
case STRING: case FIXED: case BYTES: case ENUM:
return true;
default:
return false;
}
} Try / catch
try {
spark.read().format("iceberg").load("db.tbl");
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("Unsupported type: ")) {
// verify the Avro schema matches the Iceberg table schema and rewrite the file if needed
} else {
throw e;
}
} Prevention
- Keep the Avro files' schema in sync with the Iceberg table schema (nested types must nest, not flatten)
- Validate Avro schemas with avro-tools before ingesting externally written files
- Avoid hand-edited Avro schemas; regenerate them from the canonical Iceberg schema
When it happens
Trigger: Planning an Avro read where a field's Avro schema type is not one of the handled primitive cases, e.g. a nested record/array reaching primitive() due to a schema-mapping mismatch, or an unrecognized Avro type name.
Common situations: Malformed or hand-edited Avro schemas; producer/consumer schema drift where a field changed from primitive to nested without updating the Iceberg schema; bugs in schema projection code passing the wrong schema node.
Related errors
- Unsupported type:
- Unsupported type:
- Unknown logical type: ${logicalType}
- Unsupported type: ${primitive}
- Unknown logical type:
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/abff61d68bd7e3c9.
Report an issue: GitHub.