apache/iceberg · error · IllegalArgumentException
Unsupported type: ${primitive}
Error message
Unsupported type: ${primitive} What it means
SparkPlannedAvroReader.primitive maps Avro primitive types (NULL, BOOLEAN, INT, LONG, FLOAT, DOUBLE, STRING, FIXED, BYTES, ENUM) to value readers. Any other Avro type (e.g. RECORD, ARRAY, MAP, UNION — which should be handled by other visit methods) reaching this switch throws IllegalArgumentException.
Source
Thrown at spark/v4.1/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
- Verify the table schema matches the Avro file schema; fix the Iceberg schema so planning resolves each field to the right reader.
- Re-write the Avro data with a standard schema.
- Upgrade Iceberg if the file uses an Avro feature newer than the bundled version.
Defensive patterns
Strategy: validation
Validate before calling
// ensure planned Iceberg schema fields align 1:1 with Avro primitives
avroSchema.getFields().forEach(f ->
Preconditions.checkArgument(f.schema().getType().isPrimitive() ||
f.schema().getType() == Schema.Type.ENUM ||
f.schema().getType() == Schema.Type.FIXED,
"Unexpected Avro type for field %s: %s", f.name(), f.schema().getType())); Prevention
- Keep the Iceberg table schema in sync with the underlying Avro files
- Rewrite files whose schema drifted from the table schema
- Avoid hand-edited Avro schemas
When it happens
Trigger: A nested/non-primitive Avro type routed into the primitive visit method due to a schema-planning mismatch, or a corrupted/unusual schema where a primitive branch receives an unhandled type.
Common situations: Schema incompatibility between the planned Iceberg schema and the Avro file schema (fields resolved to unexpected types); custom Avro types.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Unsupported type:
- Unsupported type: ${primitive}
- Unsupported type:
- Unknown logical type: {logicalType}
- Unknown type for int field. Type name:
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/9c1f8d26426d65e7.
Report an issue: GitHub.