apache/iceberg · error · UnsupportedOperationException
Remove is not supported
Error message
Remove is not supported
What it means
DVIterator implements Java's legacy Iterator interface, whose remove() default operation is unsupported. Iceberg's iterator over rows feeding deletion-vector writes is read-only, so any call to remove() fails fast rather than corrupting state. This is a deliberate guard: removal is meaningless for a scan-backed stream.
Source
Thrown at spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/source/DVIterator.java:104
rowValues.add(ScanTaskUtil.contentSizeInBytes(deleteFile));
} else if (fieldId == MetadataColumns.DELETE_FILE_ROW_FIELD_ID) {
// DVs don't track the row that was deleted
rowValues.add(null);
}
}
this.row = new GenericInternalRow(rowValues.toArray());
} else if (null != deletedPositionIndex) {
// only update the deleted position if necessary, everything else stays the same
row.update(deletedPositionIndex, position);
}
return row;
}
@Override
public void remove() {
throw new UnsupportedOperationException("Remove is not supported");
}
@Override
public void close() {}
}
View on GitHub (pinned to 86d9c8fc54)
Solutions
- Do not call remove(); iterate read-only and collect the rows you need.
- If filtering is required, filter upstream in the scan/plan instead of mutating during iteration.
- Use CloseableIterable.filter for filtered views instead of Iterator.remove.
Example fix
// before
while (it.hasNext()) {
Row r = it.next();
if (!keep(r)) { it.remove(); } // throws
}
// after
CloseableIterable<Row> kept = CloseableIterable.filter(rows, this::keep); Defensive patterns
Strategy: type-guard
Type guard
if (iterator instanceof DVIterator) { /* never call remove(); treat as read-only */ } Prevention
- Treat all Iceberg scan iterators as read-only
- Never use Iterator.remove() on data returned from Iceberg scans
- Prefer CloseableIterable.filter/combiner over mutation during iteration
When it happens
Trigger: Calling remove() on the Iterator returned by DVIterator, e.g. code that iterates rows and mutates the underlying collection via iterator.remove().
Common situations: Legacy Java code or third-party utilities that use Iterator.remove() while draining scan results passed into deletion-vector-producing readers.
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
- StructInternalRow is read-only
- Remove is not supported
- StructInternalRow is read-only
- Not implemented: set
- Remove is not supported
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/c1dc36b244d7babe.
Report an issue: GitHub.