{"record":{"id":"e81b501b02e0d4b7","repo":"apache/iceberg","slug":"unknown-type-for-int-field-type-name-integer-g","errorCode":null,"errorMessage":"Unknown type for int field. Type name: ${integer.getClass().getName()}","messagePattern":"Unknown type for int field\\. Type name: (.+?)","errorType":"exception","errorClass":"java.lang.IllegalStateException","httpStatus":null,"severity":"error","filePath":"flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/data/StructRowData.java","lineNumber":130,"sourceCode":"  }\n\n  @Override\n  public short getShort(int pos) {\n    return (short) (int) struct.get(pos, Integer.class);\n  }\n\n  @Override\n  public int getInt(int pos) {\n    Object integer = struct.get(pos, Object.class);\n\n    if (integer instanceof Integer) {\n      return (int) integer;\n    } else if (integer instanceof LocalDate localDate) {\n      return (int) localDate.toEpochDay();\n    } else if (integer instanceof LocalTime) {\n      return (int) (((LocalTime) integer).toNanoOfDay() / 1000_000);\n    } else {\n      throw new IllegalStateException(\n          \"Unknown type for int field. Type name: \" + integer.getClass().getName());\n    }\n  }\n\n  @Override\n  public long getLong(int pos) {\n    Object longVal = struct.get(pos, Object.class);\n\n    if (longVal instanceof Long) {\n      return (long) longVal;\n    } else if (longVal instanceof OffsetDateTime) {\n      return Duration.between(Instant.EPOCH, (OffsetDateTime) longVal).toNanos() / 1000;\n    } else if (longVal instanceof LocalDate) {\n      return ((LocalDate) longVal).toEpochDay();\n    } else if (longVal instanceof LocalTime) {\n      return ((LocalTime) longVal).toNanoOfDay();\n    } else if (longVal instanceof LocalDateTime) {\n      return Duration.between(Instant.EPOCH, ((LocalDateTime) longVal).atOffset(ZoneOffset.UTC))","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/data/StructRowData.java#L112-L148","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nint v = structRowData.getInt(pos); // value is actually String\n// after\nString v = structRowData.getString(pos); // correct accessor for stored type","handlingStrategy":"type-guard","validationCode":"Object v = structRowData.getValue(pos);\nif (!(v instanceof Integer || v instanceof Long || v instanceof LocalDate || v instanceof LocalTime || v instanceof java.util.Date)) {\n  throw new IllegalArgumentException(\"getInt unsupported value at \" + pos + \": \" + (v == null ? \"null\" : v.getClass()));\n}","typeGuard":"boolean intReadable(Object v) { return v instanceof Integer || v instanceof Long || v instanceof LocalDate || v instanceof LocalTime || v instanceof java.util.Date; }","tryCatchPattern":"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; }","preventionTips":["Match accessor to the Iceberg schema type","Validate producer object types feeding StructRowData","Add schema/data type assertions in custom connectors"],"tags":["flink","rowdata","type-mismatch","int"],"backgroundTag":"type-mismatch","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}