apache/iceberg · error · UnsupportedOperationException
Unsupported type: ${primitive}
Error message
Unsupported type: ${primitive} What it means
SparkParquetWriters.primitive() maps Spark/Iceberg primitive types to Parquet column writers and falls through to UnsupportedOperationException('Unsupported type: ...') when the physical Parquet type has no writer case, aborting the write task.
Source
Thrown at spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/data/SparkParquetWriters.java:326
"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
- Upgrade the Iceberg Spark runtime to match your data types.
- Cast unsupported columns to supported types before writing.
- Use a write format (Avro/ORC) or writer path that supports the type.
Example fix
// before
df.writeTo("tbl") // column with unsupported physical mapping
// after
df.withColumn("c", col("c").cast("string")).writeTo("tbl") Defensive patterns
Strategy: validation
Validate before calling
Schema schema = SparkSchemaUtil.convert(df.schema());
for (Types.NestedField f : schema.columns()) {
// verify types are supported by the Parquet writer for your Iceberg version
System.out.println(f.fieldId() + " -> " + f.type());
} Try / catch
try {
df.writeTo("tbl").append();
} catch (UnsupportedOperationException e) {
if (e.getMessage().startsWith("Unsupported type:")) {
// cast offending column before writing
}
} Prevention
- Cast exotic columns to supported primitives before writing.
- Keep spark-runtime and core versions identical.
When it happens
Trigger: Writing a Spark DataFrame to an Iceberg Parquet table with a column whose Parquet physical type falls outside BOOLEAN/INT32/INT64/FLOAT/DOUBLE handled in this switch (e.g. unexpected FIXED_LEN_BYTE_ARRAY or BINARY reached here via an unexpected path).
Common situations: Custom write paths or older writer code paths meeting newer types; version mismatch between Spark connector and Iceberg core.
Related errors
- Unsupported type: ${primitive}
- Unsupported type:
- Unsupported type: %s
- Unsupported type:
- Not a boolean column
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/62f188e68f77348c.
Report an issue: GitHub.