apache/iceberg · error · UnsupportedOperationException

Remove is not supported

Error message

Remove is not supported

What it means

ParquetIterator.remove() is unsupported: Parquet files are immutable, so iterator element removal is a protocol violation. It always throws UnsupportedOperationException with the message "Remove is not supported".

Solutions

  1. Do not call remove(); collect the records you want to keep into a new collection instead.
  2. If deletion is intended, delete data files via Iceberg delete operations (DeleteFiles), not the iterator.
  3. Wrap the iterator with Guava's Iterators.unmodifiableIterator to surface misuse early.

Example fix

// before
if (!predicate.test(row)) { it.remove(); }
// after
if (predicate.test(row)) { kept.add(row); }
Defensive patterns

Strategy: type-guard

Try / catch

try {
  it.remove();
} catch (UnsupportedOperationException e) {
  LOG.warn("Cannot remove from parquet iterator; collect keepers instead");
}

Prevention

When it happens

Trigger: Calling remove() on an iterator obtained from ParquetIterable.iterator(), directly or indirectly (e.g. via a collection/helper that mutates while iterating).

Common situations: Framework code that assumes mutable iterators (e.g. filtering by removing elements); porting code from in-memory collections to Parquet-backed iteration.

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/f678eb743d2d80d0. Report an issue: GitHub.

Appendix: source

Thrown at parquet/src/main/java/org/apache/iceberg/parquet/ParquetIterable.java:91

      return next;
    }

    private T advance() {
      // this must be called in hasNext because it reuses an UnsafeRow
      try {
        T nextRecord = parquet.read();
        this.needsAdvance = false;
        this.hasNext = nextRecord != null;
        return nextRecord;
      } catch (IOException e) {
        throw new RuntimeIOException(e);
      }
    }

    @Override
    public void remove() {
      throw new UnsupportedOperationException("Remove is not supported");
    }

    @Override
    public void close() throws IOException {
      parquet.close();
    }
  }
}

View on GitHub (pinned to 86d9c8fc54)