{"record":{"id":"f9af91b83dc36637","repo":"apache/iceberg","slug":"could-not-set-a-field-in-the-rowdatawrapper-becaus-f9af91","errorCode":null,"errorMessage":"Could not set a field in the RowDataWrapper because rowData is read-only","messagePattern":"Could not set a field in the RowDataWrapper because rowData is read-only","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"flink/v2.2/flink/src/main/java/org/apache/iceberg/flink/RowDataWrapper.java","lineNumber":83,"sourceCode":"  }\n\n  @Override\n  public int size() {\n    return types.length;\n  }\n\n  @Override\n  public <T> T get(int pos, Class<T> javaClass) {\n    if (rowData.isNullAt(pos)) {\n      return null;\n    }\n\n    return javaClass.cast(getters[pos].get(rowData, pos));\n  }\n\n  @Override\n  public <T> void set(int pos, T value) {\n    throw new UnsupportedOperationException(\n        \"Could not set a field in the RowDataWrapper because rowData is read-only\");\n  }\n\n  private interface PositionalGetter<T> {\n    T get(RowData data, int pos);\n  }\n\n  private static PositionalGetter<?> buildGetter(LogicalType logicalType, Type type) {\n    switch (logicalType.getTypeRoot()) {\n      case TINYINT:\n        return (row, pos) -> (int) row.getByte(pos);\n      case SMALLINT:\n        return (row, pos) -> (int) row.getShort(pos);\n      case CHAR:\n      case VARCHAR:\n        return (row, pos) -> row.getString(pos).toString();\n\n      case BINARY:","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v2.2/flink/src/main/java/org/apache/iceberg/flink/RowDataWrapper.java#L65-L101","documentation":"RowDataWrapper implements Iceberg's StructLike wrapper over Flink RowData, which is read-only. Its set(pos, value) method is therefore unimplemented and always throws UnsupportedOperationException — you cannot mutate wrapped Flink RowData through this wrapper.","triggerScenarios":"Passing a RowDataWrapper as a StructLike to any Iceberg API that mutates records, e.g. writing into a StructLike via internal record builders, copy operations, or generic updaters that call StructLike.set.","commonSituations":"Using Flink RowData in an Iceberg code path that expects a writable StructLike (e.g. building partition keys or writing records generically); reuse of a read wrapper in a write context.","solutions":["Wrap a mutable record type instead (e.g. Iceberg's Record or a GenericRecord) when writes are needed.","Copy the RowData into a writable structure before passing it to APIs that call set().","Avoid calling set(); only read via get() from this wrapper."],"exampleFix":"// before\nRowDataWrapper w = new RowDataWrapper(...); w.set(0, val); // throws\n// after\nRecord rec = GenericRecord.create(schema);\nrec.set(0, val);","handlingStrategy":"type-guard","validationCode":"if (needsMutation) { /* use a mutable Record instead of RowDataWrapper */ }","typeGuard":"boolean isMutable(StructLike s) { return !(s instanceof RowDataWrapper); }","tryCatchPattern":"if (isMutable(structLike)) { structLike.set(pos, value); } else { /* copy into Record first */ }","preventionTips":["Treat RowDataWrapper as strictly read-only","Copy RowData into Iceberg Record when mutation is required","Review StructLike call-sites for set() usage before passing Flink wrappers"],"tags":["flink","read-only","structlike"],"backgroundTag":"unsupported-operation","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}