apache/iceberg · error · IllegalStateException
Invalid iceberg type %s corresponding to ORC type %s
Error message
Invalid iceberg type %s corresponding to ORC type %s
What it means
GenericOrcReader.primitive() maps an Iceberg primitive type to an ORC value reader. Inside the ORC INT/long-compatible branch, a TIME or LONG Iceberg type is handled, but any other Iceberg primitive reaching that default arm is rejected with IllegalStateException because there is no valid reader mapping.
Source
Thrown at orc/src/main/java/org/apache/iceberg/data/orc/GenericOrcReader.java:128
}
switch (primitive.getCategory()) {
case BOOLEAN:
return OrcValueReaders.booleans();
case BYTE:
// Iceberg does not have a byte type. Use int
case SHORT:
// Iceberg does not have a short type. Use int
case INT:
return OrcValueReaders.ints();
case LONG:
switch (iPrimitive.typeId()) {
case TIME:
return GenericOrcReaders.times();
case LONG:
return OrcValueReaders.longs();
default:
throw new IllegalStateException(
String.format(
"Invalid iceberg type %s corresponding to ORC type %s",
iPrimitive, primitive));
}
case FLOAT:
return OrcValueReaders.floats();
case DOUBLE:
return OrcValueReaders.doubles();
case DATE:
return GenericOrcReaders.dates();
case TIMESTAMP:
return GenericOrcReaders.timestamps();
case TIMESTAMP_INSTANT:
return GenericOrcReaders.timestampTzs();
case DECIMAL:
return GenericOrcReaders.decimals();
case CHAR:View on GitHub (pinned to 86d9c8fc54)
Solutions
- Align the Iceberg schema with the actual ORC file schema (update the table schema).
- Rewrite the data files with a matching Iceberg type.
- Upgrade Iceberg to a version handling the needed type mapping.
- Inspect the ORC file schema (orc-tools) to identify the offending column and correct the mapping.
Example fix
// before
Types.TimestampType ts = (Types.TimestampType) type; // treated as INT in ORC, hits default
// after
if (iPrimitive.typeId() == Types.TimestampType.class.asSubclass(...)) {
return GenericOrcReaders.timestamp(); // use the explicitly supported reader
} Defensive patterns
Strategy: validation
Validate before calling
// verify schema type is supported before reading
if (!SUPPORTED.get(iPrimitive.typeId())) throw new IllegalArgumentException("unsupported mapping for " + iPrimitive); Type guard
boolean isSupportedMapping = iPrimitive instanceof Types.LongType || iPrimitive instanceof Types.TimeType;
Prevention
- Keep table schema in sync with ORC file schema
- Use schema evolution APIs instead of hand edits
- Test read paths after schema changes
- Inspect ORC file schema with orc-tools before remapping
When it happens
Trigger: Reading an ORC file whose column type maps to this switch arm while the Iceberg schema declares a primitive type not handled in that branch (type mismatch between the Iceberg schema and the ORC file written by another writer).
Common situations: Schema evolution mismatch; ORC files written by an older Iceberg version or third-party tool with types the reader doesn't expect; corrupted or hand-edited ORC type mappings.
Understand the failure class
Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.
Related errors
- Invalid iceberg type %s corresponding to ORC type %s
- Unhandled type
- Unsupported type:
- Invalid iceberg type %s corresponding to Flink logical type
- Invalid iceberg type %s corresponding to ORC type %s
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/70690b27a4241469.
Report an issue: GitHub.