apache/iceberg · error · UnsupportedOperationException
Unsupported type:
Error message
Unsupported type:
What it means
SparkParquetWriters.primitive() maps Iceberg primitive types to Parquet physical writers (booleans, ints, longs, floats, doubles, etc.). If an Iceberg type maps to a Parquet primitive not handled by the switch, it throws UnsupportedOperationException with the column descriptor's primitive type. Writer construction for the file fails before any data is written.
Source
Thrown at spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/data/SparkParquetWriters.java:312
"Unsupported logical type: " + primitive.getLogicalTypeAnnotation()));
}
switch (primitive.getPrimitiveTypeName()) {
case FIXED_LEN_BYTE_ARRAY:
case BINARY:
return byteArrays(desc);
case BOOLEAN:
return ParquetValueWriters.booleans(desc);
case INT32:
return ints(sType, desc);
case INT64:
return ParquetValueWriters.longs(desc);
case FLOAT:
return ParquetValueWriters.floats(desc);
case DOUBLE:
return ParquetValueWriters.doubles(desc);
default:
throw new UnsupportedOperationException("Unsupported type: " + primitive);
}
}
}
private static PrimitiveWriter<?> ints(DataType type, ColumnDescriptor desc) {
if (type instanceof ByteType) {
return ParquetValueWriters.tinyints(desc);
} else if (type instanceof ShortType) {
return ParquetValueWriters.shorts(desc);
}
return ParquetValueWriters.ints(desc);
}
private static PrimitiveWriter<UTF8String> utf8Strings(ColumnDescriptor desc) {
return new UTF8StringWriter(desc);
}
private static PrimitiveWriter<UTF8String> uuids(ColumnDescriptor desc) {View on GitHub (pinned to 86d9c8fc54)
Solutions
- Check the table schema and find which column maps to the unsupported primitive type
- ALTER the table column to a supported type or cast it before writing (e.g. cast to long/string)
- Upgrade Iceberg so the type has writer support in this Spark version
- Avoid custom descriptor overrides; let the writer derive Parquet types from the Iceberg schema
Example fix
// before
df.writeTo("db.tbl").append(); // fails on unsupported primitive
// after
df.withColumn("col", functions.col("col").cast("long"))
.writeTo("db.tbl").append(); Defensive patterns
Strategy: validation
Validate before calling
table.schema().columns().forEach(f -> {
if (!SUPPORTED_WRITE_TYPE_IDS.contains(f.type().typeId())) {
throw new IllegalStateException("Column " + f.name() + " type " + f.type() + " has no Parquet writer");
}
}); Type guard
boolean isParquetWritable(Type type) {
switch (type.typeId()) {
case BOOLEAN: case INT: case LONG: case FLOAT: case DOUBLE: case DATE:
case TIMESTAMP: case STRING: case BINARY: case DECIMAL: case FIXED: case UUID:
return true;
default: return false;
}
} Try / catch
try {
df.writeTo("db.tbl").append();
} catch (UnsupportedOperationException e) {
if (e.getMessage().startsWith("Unsupported type: ")) {
// cast or alter the offending column, then retry
} else {
throw e;
}
} Prevention
- Check Iceberg-to-Parquet type coverage before adding new column types to the table
- Avoid custom column-descriptor overrides; derive Parquet types from the Iceberg schema
- Upgrade Iceberg together with schema changes that introduce newer spec types
When it happens
Trigger: Writing an Iceberg table as Parquet from Spark where a column resolves to a Parquet primitive type outside the handled cases of the switch.
Common situations: Schema evolution that promoted a column into a type without writer support in this branch; custom write paths supplying non-standard column descriptors; newer Iceberg spec types written with an older Spark integration.
Related errors
- Unsupported type: ${primitive}
- Unsupported type: ${primitive}
- Unsupported type: %s
- Unsupported type:
- Not a boolean column
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/b3797a36e13d4c36.
Report an issue: GitHub.