{"record":{"id":"f678eb743d2d80d0","repo":"apache/iceberg","slug":"remove-is-not-supported","errorCode":null,"errorMessage":"Remove is not supported","messagePattern":"Remove is not supported","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"parquet/src/main/java/org/apache/iceberg/parquet/ParquetIterable.java","lineNumber":91,"sourceCode":"\n      return next;\n    }\n\n    private T advance() {\n      // this must be called in hasNext because it reuses an UnsafeRow\n      try {\n        T nextRecord = parquet.read();\n        this.needsAdvance = false;\n        this.hasNext = nextRecord != null;\n        return nextRecord;\n      } catch (IOException e) {\n        throw new RuntimeIOException(e);\n      }\n    }\n\n    @Override\n    public void remove() {\n      throw new UnsupportedOperationException(\"Remove is not supported\");\n    }\n\n    @Override\n    public void close() throws IOException {\n      parquet.close();\n    }\n  }\n}\n","sourceCodeStart":73,"sourceCodeEnd":100,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/parquet/src/main/java/org/apache/iceberg/parquet/ParquetIterable.java#L73-L100","documentation":"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\".","triggerScenarios":"Calling remove() on an iterator obtained from ParquetIterable.iterator(), directly or indirectly (e.g. via a collection/helper that mutates while iterating).","commonSituations":"Framework code that assumes mutable iterators (e.g. filtering by removing elements); porting code from in-memory collections to Parquet-backed iteration.","solutions":["Do not call remove(); collect the records you want to keep into a new collection instead.","If deletion is intended, delete data files via Iceberg delete operations (DeleteFiles), not the iterator.","Wrap the iterator with Guava's Iterators.unmodifiableIterator to surface misuse early."],"exampleFix":"// before\nif (!predicate.test(row)) { it.remove(); }\n// after\nif (predicate.test(row)) { kept.add(row); }","handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  it.remove();\n} catch (UnsupportedOperationException e) {\n  LOG.warn(\"Cannot remove from parquet iterator; collect keepers instead\");\n}","preventionTips":["Treat Parquet-backed iterators as read-only.","Filter by collecting wanted records, not removing unwanted ones.","Use Iceberg delete APIs for actual data removal."],"tags":["parquet","iterator","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}