apache/iceberg · error · IllegalArgumentException
Unsupported type:
Error message
Unsupported type:
What it means
SparkAvroWriter.primitive converts Avro primitive types into Iceberg value writers. The switch covers all standard Avro primitives (BOOLEAN, INT, LONG, FLOAT, DOUBLE, STRING, FIXED, BYTES, etc.); the default branch should be unreachable but fires if an unexpected/unrecognized primitive appears. This IllegalArgumentException signals an Avro primitive the writer does not handle.
Source
Thrown at spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/data/SparkAvroWriter.java:166
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
- Inspect the Avro schema and replace unsupported primitives with standard ones.
- Align Avro library versions between your app and Iceberg's dependency set.
- Upgrade Iceberg to get a writer covering the primitive.
- Pre-convert the data to a supported primitive type before writing.
Defensive patterns
Strategy: validation
Validate before calling
// Validate all Avro primitives are standard before writing
Set<org.apache.avro.Schema.Type> standard = EnumSet.of(
org.apache.avro.Schema.Type.BOOLEAN, org.apache.avro.Schema.Type.INT,
org.apache.avro.Schema.Type.LONG, org.apache.avro.Schema.Type.FLOAT,
org.apache.avro.Schema.Type.DOUBLE, org.apache.avro.Schema.Type.STRING,
org.apache.avro.Schema.Type.FIXED, org.apache.avro.Schema.Type.BYTES,
org.apache.avro.Schema.Type.NULL);
// walk the schema and assert every leaf type is in `standard` Type guard
static boolean isStandardPrimitive(org.apache.avro.Schema s) {
return standard.contains(s.getType());
} Prevention
- Use standard Avro primitive types only
- Keep Avro library versions aligned with Iceberg's
- Validate dynamically generated schemas before writing
When it happens
Trigger: Writing data whose Avro schema contains a primitive type not covered by the writer's switch (e.g. NULL-type fields surfacing in unusual positions, or corrupted/foreign schema objects passed as Avro primitives).
Common situations: Rare in practice: encountered with hand-built or dynamically generated Avro schemas, or when Iceberg's writer is version-mismatched with an Avro library emitting new primitive kinds.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Unsupported type: variant
- Unsupported type:
- Unsupported type:
- Unsupported Avro type '${schema.getType()}'.
- Unsupported Avro type '${schema.getType()}'.
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/db9fa8156e059f3f.
Report an issue: GitHub.