{"record":{"id":"e6f8686f977e3be2","repo":"apache/iceberg","slug":"write-is-not-supported","errorCode":null,"errorMessage":"write is not supported.","messagePattern":"write is not supported\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"mr/src/main/java/org/apache/iceberg/mr/mapred/Container.java","lineNumber":44,"sourceCode":" * A simple container of objects that you can get and set.\n *\n * @param <T> the Java type of the object held by this container\n */\npublic class Container<T> implements Writable {\n\n  private T value;\n\n  public T get() {\n    return value;\n  }\n\n  public void set(T newValue) {\n    this.value = newValue;\n  }\n\n  @Override\n  public void write(DataOutput dataOutput) {\n    throw new UnsupportedOperationException(\"write is not supported.\");\n  }\n\n  @Override\n  public void readFields(DataInput dataInput) {\n    throw new UnsupportedOperationException(\"readFields is not supported.\");\n  }\n}\n","sourceCodeStart":26,"sourceCodeEnd":52,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/mr/src/main/java/org/apache/iceberg/mr/mapred/Container.java#L26-L52","documentation":"Container<T> is a read-only WritableComparable wrapper used by Iceberg's MapReduce integration to hold deserialized records. Serialization back to DataOutput is deliberately unsupported because values are never written out through this container, so write() always throws UnsupportedOperationException.","triggerScenarios":"Calling Container.write(DataOutput) directly, or a framework/job path that serializes map output or job output through the Container (e.g. using Container as a MapReduce output value class).","commonSituations":"Custom MR jobs reusing Iceberg's mapred Container as a Writable for shuffle or output; framework code assuming all value classes are fully Writable.","solutions":["Do not use Container as an output/shuffle value type; copy the underlying value into a proper Writable (or Avro/Parquet record) before writing.","If you need to persist the value, serialize value().getClass() data yourself rather than calling Container.write.","Use the mapreduce (o.a.i.mr.mapreduce) API or DataFrame/Spark APIs for jobs that must serialize values."],"exampleFix":"// before\ncontainer.write(out); // UnsupportedOperationException\n// after\ncopyOfValue.write(out); // serialize an actual Writable value, not the Container","handlingStrategy":"type-guard","validationCode":"if (value instanceof Container) {\n  throw new IllegalStateException(\"Container is read-only; copy value before writing\");\n}","typeGuard":"boolean isWritableValue(Object v) {\n  return !(v instanceof org.apache.iceberg.mr.mapred.Container);\n}","tryCatchPattern":"try { writable.write(out); }\ncatch (UnsupportedOperationException e) { throw new IOException(\"value type not serializable\", e); }","preventionTips":["Never use Container as output/intermediate value class","Copy Container.get() into a real Writable for shuffle","Prefer IcebergInputFormat (mapreduce) for jobs needing serialization"],"tags":["mapreduce","writable","read-only"],"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"}