apache/iceberg · error · IllegalArgumentException
Unsupported type:
Error message
Unsupported type:
What it means
SparkAvroWriter.primitive switches over the Avro primitive type and only supports STRING, FIXED, BYTES (among the tail cases); any other primitive type falls to the default branch and throws IllegalArgumentException('Unsupported type: ' + primitive). It guards the Avro-to-Spark value-writer mapping.
Source
Thrown at spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/data/SparkAvroWriter.java:171
return ValueWriters.tinyints();
} else if (type instanceof ShortType) {
return ValueWriters.shorts();
}
return ValueWriters.ints();
case LONG:
return ValueWriters.longs();
case FLOAT:
return ValueWriters.floats();
case DOUBLE:
return ValueWriters.doubles();
case STRING:
return SparkValueWriters.strings();
case FIXED:
return ValueWriters.fixed(primitive.getFixedSize());
case BYTES:
return ValueWriters.bytes();
default:
throw new IllegalArgumentException("Unsupported type: " + primitive);
}
}
}
}
View on GitHub (pinned to 86d9c8fc54)
Solutions
- Check the Avro schema and restrict fields to supported primitive types
- Upgrade the Iceberg version in case support was added later
- Convert unsupported primitives to supported equivalents before writing
- Inspect the full exception message for the offending primitive type
Example fix
// before: writing a schema with unsupported primitive Schema schema = Schema.createUnion(...); // after: normalize to supported primitives Schema schema = Schema.create(Schema.Type.BYTES);
Defensive patterns
Strategy: validation
Validate before calling
for (Schema.Field f : avroSchema.getFields()) {
Schema.Type t = f.schema().getType();
Preconditions.checkArgument(
t == Schema.Type.STRING || t == Schema.Type.FIXED || t == Schema.Type.BYTES
|| /* other supported types */ true, "Unsupported type: " + t);
} Try / catch
try { writer.write(row); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith("Unsupported type: ")) { /* normalize schema */ } else { throw e; } } Prevention
- Validate the Avro write schema against supported primitives before writing
- Avoid hand-built Avro schemas; derive them from the Iceberg table schema
- Upgrade the runtime if new primitive support is needed
When it happens
Trigger: Writing Spark rows to Avro whose schema contains a primitive type the writer doesn't map (e.g. unexpected/unsupported primitive in the resolved write schema).
Common situations: Schema evolution or hand-built Avro schemas with primitives outside the supported set; mismatch between the table schema and the generated Avro write schema in a custom pipeline.
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 logical type:
- Unsupported logical type: {logicalType}
- Unsupported type: {primitive}
- Unsupported logical type: ${logicalType}
- Unsupported type: ${primitive}
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/e0f52be795863ffd.
Report an issue: GitHub.