apache/iceberg · warning · UnsupportedOperationException

Remove is not supported

Error message

Remove is not supported

What it means

Iterator contract guard in DVIterator.remove: this iterator over rows filtered by deletion vectors supports forward iteration only; the optional remove() mutation is not implemented and always throws. It fires only if a caller invokes remove() on the iterator.

Source

Thrown at spark/v4.1/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

  1. Do not call remove() on this iterator
  2. Wrap in an immutable collection (ImmutableList.copyOf) if mutation is attempted downstream
  3. Use a different data structure if removal is required

Example fix

// before
it.remove();
// after — copy if you need a modifiable collection
List<InternalRow> rows = Lists.newArrayList(iterator);
Defensive patterns

Strategy: fallback

Try / catch

try { it.remove(); } catch (UnsupportedOperationException e) { /* iterators from Iceberg are read-only */ }

Prevention

When it happens

Trigger: Calling remove() on the iterator produced by DVIterator, e.g. generic code that mutates an Iterator.

Common situations: Legacy code or frameworks that call Iterator.remove() on any iterator; wrapping the DV iterator in collection utilities that mutate.

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