apache/iceberg · error · IllegalArgumentException
Unsupported type: ${primitive}
Error message
Unsupported type: ${primitive} What it means
SparkAvroWriter.primitive's final switch maps Avro primitive types (INT, LONG, FLOAT, DOUBLE, BOOLEAN, STRING, FIXED, BYTES, etc.) to value writers and throws IllegalArgumentException for any remaining type. It is the terminal guard for Avro types the Spark writer cannot serialize.
Source
Thrown at spark/v4.2/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
- Remove/replace the unsupported field in the Avro schema before writing.
- Upgrade the Iceberg runtime if the type should be supported by a newer writer.
- Cast the offending column to a supported type upstream of the write.
Defensive patterns
Strategy: validation
Validate before calling
// validate Avro schema contains only supported primitives before write
for (Schema.Field f : schema.getFields()) { /* check f.schema().getType() in supported set */ } Type guard
boolean supported(Schema s) { switch (s.getType()) { case INT: case LONG: case FLOAT: case DOUBLE: case BOOLEAN: case STRING: case FIXED: case BYTES: return true; default: return false; } } Try / catch
try { write(dataset); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith("Unsupported type")) { /* correct schema */ } else throw e; } Prevention
- Sanitize externally generated Avro schemas before Iceberg writes
- Drop NULL-typed or exotic primitive fields
- Cast unsupported columns to supported primitives upstream
When it happens
Trigger: Writing a Spark dataset to Iceberg Avro format when the schema contains an Avro primitive type outside the handled set (e.g. NULL type reaching this switch, or exotic primitives).
Common situations: Malformed or auto-generated Avro schemas with NULL-typed fields; schemas from external tools with unusual primitives.
Related errors
- Unsupported type: {primitive}
- Unsupported logical type: ${logicalType}
- Unsupported type: %s
- Unsupported logical type:
- Unsupported type:
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/c8f68776eb188de5.
Report an issue: GitHub.