apache/iceberg · error · java.lang.IllegalStateException
Unknown type for int field. Type name: ${integer.getClass().
Error message
Unknown type for int field. Type name: ${integer.getClass().getName()} What it means
StructRowData.getInt(pos) converts an internal object value into a Flink INT. It supports Integer, Long, Date (epoch days) widening paths and LocalDate/LocalTime, but if the stored value is any other class the library throws IllegalStateException naming the actual class. It is an internal conversion contract violation between the Iceberg value model and the Flink reader.
Source
Thrown at flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/data/StructRowData.java:130
}
@Override
public short getShort(int pos) {
return (short) (int) struct.get(pos, Integer.class);
}
@Override
public int getInt(int pos) {
Object integer = struct.get(pos, Object.class);
if (integer instanceof Integer) {
return (int) integer;
} else if (integer instanceof LocalDate localDate) {
return (int) localDate.toEpochDay();
} else if (integer instanceof LocalTime) {
return (int) (((LocalTime) integer).toNanoOfDay() / 1000_000);
} else {
throw new IllegalStateException(
"Unknown type for int field. Type name: " + integer.getClass().getName());
}
}
@Override
public long getLong(int pos) {
Object longVal = struct.get(pos, Object.class);
if (longVal instanceof Long) {
return (long) longVal;
} else if (longVal instanceof OffsetDateTime) {
return Duration.between(Instant.EPOCH, (OffsetDateTime) longVal).toNanos() / 1000;
} else if (longVal instanceof LocalDate) {
return ((LocalDate) longVal).toEpochDay();
} else if (longVal instanceof LocalTime) {
return ((LocalTime) longVal).toNanoOfDay();
} else if (longVal instanceof LocalDateTime) {
return Duration.between(Instant.EPOCH, ((LocalDateTime) longVal).atOffset(ZoneOffset.UTC))View on GitHub (pinned to 86d9c8fc54)
Solutions
- Check the Iceberg schema: the column must be int/date/time compatible with getInt
- Log/inspect the value at pos and fix the producer so it stores Integer/Long/LocalDate/LocalTime
- Use getLong/getString (the correct accessor) for the actual stored type
Example fix
// before int v = structRowData.getInt(pos); // value is actually String // after String v = structRowData.getString(pos); // correct accessor for stored type
Defensive patterns
Strategy: type-guard
Validate before calling
Object v = structRowData.getValue(pos);
if (!(v instanceof Integer || v instanceof Long || v instanceof LocalDate || v instanceof LocalTime || v instanceof java.util.Date)) {
throw new IllegalArgumentException("getInt unsupported value at " + pos + ": " + (v == null ? "null" : v.getClass()));
} Type guard
boolean intReadable(Object v) { return v instanceof Integer || v instanceof Long || v instanceof LocalDate || v instanceof LocalTime || v instanceof java.util.Date; } Try / catch
try { int x = row.getInt(pos); } catch (IllegalStateException e) { if (e.getMessage().startsWith("Unknown type for int field")) { Object v = row.getValue(pos); /* route to matching accessor */ } else throw e; } Prevention
- Match accessor to the Iceberg schema type
- Validate producer object types feeding StructRowData
- Add schema/data type assertions in custom connectors
When it happens
Trigger: Calling getInt on a StructRowData whose underlying field holds an unsupported object type — e.g. a String, BigDecimal, or TimestampData where an int-representable value (int/long/date/time) was expected.
Common situations: Schema mismatch between the Iceberg schema and the actual in-memory values (e.g. field declared Integer but data is string); custom source implementations feeding wrong types into StructRowData.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Unknown type for int field. Type name: ${className}
- Unknown type for long field. Type name: ${className}
- Unknown type for timestamp_ns: ${class}
- Unknown type for long field. Type name: ${longVal.getClass()
- Unknown type for timestamp_ns: ${timeVal.getClass()}
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/e81b501b02e0d4b7.
Report an issue: GitHub.