apache/iceberg · error · IllegalArgumentException
Unsupported logical type: ${logicalType}
Error message
Unsupported logical type: ${logicalType} What it means
SparkAvroWriter.primitive builds Avro value writers for a Spark primitive type; within a STRING branch it handles known logical types (decimal, uuid) and throws IllegalArgumentException for any other Avro logical type annotation it doesn't recognize.
Source
Thrown at spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/data/SparkAvroWriter.java:142
if (logicalType != null) {
switch (logicalType.getName()) {
case "date":
// Spark uses the same representation
return ValueWriters.ints();
case "timestamp-micros":
// Spark uses the same representation
return ValueWriters.longs();
case "decimal":
LogicalTypes.Decimal decimal = (LogicalTypes.Decimal) logicalType;
return SparkValueWriters.decimal(decimal.getPrecision(), decimal.getScale());
case "uuid":
return SparkValueWriters.uuids();
default:
throw new IllegalArgumentException("Unsupported logical type: " + logicalType);
}
}
switch (primitive.getType()) {
case NULL:
return ValueWriters.nulls();
case BOOLEAN:
return ValueWriters.booleans();
case INT:
if (type instanceof ByteType) {
return ValueWriters.tinyints();
} else if (type instanceof ShortType) {
return ValueWriters.shorts();
}
return ValueWriters.ints();
case LONG:
return ValueWriters.longs();
case FLOAT:View on GitHub (pinned to 86d9c8fc54)
Solutions
- Upgrade the Iceberg runtime so the writer recognizes the logical type.
- Adjust the Avro schema to drop the unsupported logical type annotation if the underlying primitive is what you intend.
- Convert the data to a supported type before writing.
Defensive patterns
Strategy: validation
Validate before calling
// verify Avro schema logical types are only decimal or uuid before writing
if (!Set.of("decimal", "uuid").contains(logicalTypeName)) throw new IllegalArgumentException("unsupported"); Type guard
if ("string".equals(primitive.getType().getName()) && logicalType != null && !"decimal".equals(logicalType.getName()) && !"uuid".equals(logicalType.getName())) { /* unsupported */ } Try / catch
try { write(dataset); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith("Unsupported logical type")) { /* fix schema */ } else throw e; } Prevention
- Restrict Avro schema logical types to decimal and uuid
- Validate source Avro schemas before configuring writes
- Upgrade runtime for newer logical type support
When it happens
Trigger: Writing Spark data to Iceberg Avro files when an Avro string primitive carries a logicalType name not in the supported set (only decimal and uuid are handled).
Common situations: Avro schemas with custom/less-common logical types (e.g. time-micros annotations on unexpected types) feeding the writer path; schema from a newer spec writer.
Related errors
- Unsupported type: {primitive}
- Unsupported type: ${primitive}
- Unsupported type: %s
- Unsupported logical type:
- Unsupported type:
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/144ce9c1e4b98076.
Report an issue: GitHub.