{"record":{"id":"07c51ae785692b62","repo":"apache/iceberg","slug":"setting-values-is-not-supported","errorCode":null,"errorMessage":"Setting values is not supported","messagePattern":"Setting values is not supported","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/StaticDataTask.java","lineNumber":163,"sourceCode":"    private final Object[] values;\n\n    private Row(Object... values) {\n      this.values = values;\n    }\n\n    @Override\n    public int size() {\n      return values.length;\n    }\n\n    @Override\n    public <T> T get(int pos, Class<T> javaClass) {\n      return javaClass.cast(values[pos]);\n    }\n\n    @Override\n    public <T> void set(int pos, T value) {\n      throw new UnsupportedOperationException(\"Setting values is not supported\");\n    }\n  }\n}\n","sourceCodeStart":145,"sourceCodeEnd":167,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/StaticDataTask.java#L145-L167","documentation":"StaticDataTask's internal StructLike implementation throws UnsupportedOperationException from set() because static data tasks expose immutable, read-only rows backed by a fixed values array. Iceberg models row mutation as unsupported here by design: static tables are read-only snapshots of data at a point in time. Any code path that attempts to write into a row from a static task is a programming error.","triggerScenarios":"Calling StructLike.set(pos, value) on a record obtained from a StaticDataTask (e.g. rows yielded by metadata tables like table.metadataTable(\"entries\") or static table scans), or passing such a StructLike into an API that mutates records in place (some writers/updaters do).","commonSituations":"Generic code that assumes every StructLike is mutable (e.g. reuse-a-record write patterns) being fed rows from metadata-table scans; copying logic that mutates the destination record; unit tests reusing records across static task iterations.","solutions":["Do not mutate rows from static tasks; instead build a new record/copy when you need a modified value.","If your writer mutates a reused record, allocate a fresh mutable StructLike (e.g. your own GenericRecord or array-backed implementation) instead of reusing the task's record.","When buffering rows for rewriting, wrap the immutable record in your own mutable container and copy values via get().","If you need updatable data, scan the actual data table rather than a static/metadata table."],"exampleFix":"// before\nStructLike row = tasks.iterator().next();\nrow.set(0, newValue); // UnsupportedOperationException\n\n// after\nStructLike src = tasks.iterator().next();\nStructLike copy = new InternalRecord(/* mutable impl */);\nfor (int i = 0; i < copy.size(); i++) { copy.set(i, src.get(i, Object.class)); }\ncopy.set(0, newValue);","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"// Java\nboolean isMutable(StructLike row) {\n  return !(row instanceof StaticDataTask.Record);\n}","tryCatchPattern":"// Java\ntry {\n  row.set(pos, value);\n} catch (UnsupportedOperationException e) {\n  // clone into a mutable StructLike and retry\n  StructLike copy = copyOf(row);\n  copy.set(pos, value);\n}","preventionTips":["Treat StructLike rows from metadata/static table scans as immutable.","Copy values into your own mutable record before rewriting rows.","Avoid writer code paths that mutate records in place when consuming static task output."],"tags":["immutable","structlike","read-only","iceberg"],"backgroundTag":"unsupported-operation","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"}