apache/iceberg · error · UnsupportedOperationException

Cannot copy

Error message

Cannot copy

What it means

ManifestFileBean.copy() is intentionally unimplemented: these beans are deserialized carriers of manifest file info and are never supposed to be copied; calling copy() always throws UnsupportedOperationException("Cannot copy").

Source

Thrown at spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/actions/ManifestFileBean.java:199

  @Override
  public List<PartitionFieldSummary> partitions() {
    return null;
  }

  @Override
  public ByteBuffer keyMetadata() {
    return keyMetadata == null ? null : ByteBuffer.wrap(keyMetadata);
  }

  @Override
  public Long firstRowId() {
    return firstRowId;
  }

  @Override
  public ManifestFile copy() {
    throw new UnsupportedOperationException("Cannot copy");
  }
}

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Do not call copy() on ManifestFileBean; construct a new ManifestFileBean or keep the reference as-is
  2. If a real ManifestFile is needed, build one from the bean's fields (path, partition spec id, etc.) or use the original ManifestFile from the snapshot
  3. Wrap in an adapter implementing copy() by constructing a fresh ImmutableGenericManifestFile if your code requires the ManifestFile interface

Example fix

// before
ManifestFile copy = manifestBean.copy(); // throws
// after
ManifestFile copy = new ManifestFileBean(...fields copied from manifestBean...); // or keep the bean
Defensive patterns

Strategy: type-guard

Validate before calling

if (file instanceof ManifestFileBean) { /* do not call copy() */ }

Type guard

boolean copyable = !(f instanceof ManifestFileBean);

Prevention

When it happens

Trigger: Calling copy() on a ManifestFileBean obtained from a rewrite/partial-progress path (e.g. iterating RewriteFileGroup manifests and treating them as regular ManifestFiles that support copy).

Common situations: Custom code that collects ManifestFile instances from a datastream of ManifestFileBeans and calls copy() (e.g. to detach from a reusable container), or new Iceberg code paths added on top of these beans.

Related errors


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