apache/iceberg · error · UnsupportedOperationException

write is not supported.

Error message

write is not supported.

What it means

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.

Solutions

  1. Do not use Container as an output/shuffle value type; copy the underlying value into a proper Writable (or Avro/Parquet record) before writing.
  2. If you need to persist the value, serialize value().getClass() data yourself rather than calling Container.write.
  3. Use the mapreduce (o.a.i.mr.mapreduce) API or DataFrame/Spark APIs for jobs that must serialize values.

Example fix

// before
container.write(out); // UnsupportedOperationException
// after
copyOfValue.write(out); // serialize an actual Writable value, not the Container
Defensive patterns

Strategy: type-guard

Validate before calling

if (value instanceof Container) {
  throw new IllegalStateException("Container is read-only; copy value before writing");
}

Type guard

boolean isWritableValue(Object v) {
  return !(v instanceof org.apache.iceberg.mr.mapred.Container);
}

Try / catch

try { writable.write(out); }
catch (UnsupportedOperationException e) { throw new IOException("value type not serializable", e); }

Prevention

When it happens

Trigger: 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).

Common situations: Custom MR jobs reusing Iceberg's mapred Container as a Writable for shuffle or output; framework code assuming all value classes are fully Writable.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/e6f8686f977e3be2. Report an issue: GitHub.

Appendix: source

Thrown at mr/src/main/java/org/apache/iceberg/mr/mapred/Container.java:44

 * A simple container of objects that you can get and set.
 *
 * @param <T> the Java type of the object held by this container
 */
public class Container<T> implements Writable {

  private T value;

  public T get() {
    return value;
  }

  public void set(T newValue) {
    this.value = newValue;
  }

  @Override
  public void write(DataOutput dataOutput) {
    throw new UnsupportedOperationException("write is not supported.");
  }

  @Override
  public void readFields(DataInput dataInput) {
    throw new UnsupportedOperationException("readFields is not supported.");
  }
}

View on GitHub (pinned to 86d9c8fc54)