{"record":{"id":"d5efd4ba2b90bcc0","repo":"apache/iceberg","slug":"remove-is-not-supported-d5efd4","errorCode":null,"errorMessage":"Remove is not supported","messagePattern":"Remove is not supported","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"warning","filePath":"spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/source/DVIterator.java","lineNumber":104,"sourceCode":"          rowValues.add(ScanTaskUtil.contentSizeInBytes(deleteFile));\n        } else if (fieldId == MetadataColumns.DELETE_FILE_ROW_FIELD_ID) {\n          // DVs don't track the row that was deleted\n          rowValues.add(null);\n        }\n      }\n\n      this.row = new GenericInternalRow(rowValues.toArray());\n    } else if (null != deletedPositionIndex) {\n      // only update the deleted position if necessary, everything else stays the same\n      row.update(deletedPositionIndex, position);\n    }\n\n    return row;\n  }\n\n  @Override\n  public void remove() {\n    throw new UnsupportedOperationException(\"Remove is not supported\");\n  }\n\n  @Override\n  public void close() {}\n}\n","sourceCodeStart":86,"sourceCodeEnd":110,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/source/DVIterator.java#L86-L110","documentation":"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.","triggerScenarios":"Calling remove() on the iterator produced by DVIterator, e.g. generic code that mutates an Iterator.","commonSituations":"Legacy code or frameworks that call Iterator.remove() on any iterator; wrapping the DV iterator in collection utilities that mutate.","solutions":["Do not call remove() on this iterator","Wrap in an immutable collection (ImmutableList.copyOf) if mutation is attempted downstream","Use a different data structure if removal is required"],"exampleFix":"// before\nit.remove();\n// after — copy if you need a modifiable collection\nList<InternalRow> rows = Lists.newArrayList(iterator);","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { it.remove(); } catch (UnsupportedOperationException e) { /* iterators from Iceberg are read-only */ }","preventionTips":["Treat Iceberg iterators as forward-only","Copy into a mutable collection if removal is needed"],"tags":["spark","iceberg","iterator","read-only"],"backgroundTag":"unsupported-operation","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}