{"record":{"id":"4463067fd57e2776","repo":"apache/iceberg","slug":"this-getclass-getname-does-not-implement-in-446306","errorCode":null,"errorMessage":"this.getClass().getName() +  does not implement insert","messagePattern":"this\\.getClass\\(\\)\\.getName\\(\\) \\+  does not implement insert","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/source/SparkPositionDeltaWrite.java","lineNumber":650,"sourceCode":"      InternalRow partition = metadata.getStruct(partitionOrdinal, partitionRowWrapper.size());\n      StructProjection partitionProjection = partitionProjections.get(specId);\n      partitionProjection.wrap(partitionRowWrapper.wrap(partition));\n\n      String file = id.getString(fileOrdinal);\n      long position = id.getLong(positionOrdinal);\n      positionDelete.set(file, position);\n      delegate.write(positionDelete, spec, partitionProjection);\n    }\n\n    @Override\n    public void update(InternalRow metadata, InternalRow id, InternalRow row) {\n      throw new UnsupportedOperationException(\n          this.getClass().getName() + \" does not implement update\");\n    }\n\n    @Override\n    public void insert(InternalRow row) throws IOException {\n      throw new UnsupportedOperationException(\n          this.getClass().getName() + \" does not implement insert\");\n    }\n\n    @Override\n    public WriterCommitMessage commit() throws IOException {\n      close();\n\n      DeleteWriteResult result = delegate.result();\n      return new DeltaTaskCommit(result);\n    }\n\n    @Override\n    public void abort() throws IOException {\n      close();\n\n      DeleteWriteResult result = delegate.result();\n      SparkCleanupUtil.deleteTaskFiles(io, result.deleteFiles());\n    }","sourceCodeStart":632,"sourceCodeEnd":668,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/source/SparkPositionDeltaWrite.java#L632-L668","documentation":"This position-delete writer in SparkPositionDeltaWrite does not implement insert() — row insertion is handled by the paired data writer or via reinsert() in MoR variants. Calling insert() on this specific writer deliberately throws UnsupportedOperationException.","triggerScenarios":"Code calls insert(row) on the copy-on-write position-delete writer of SparkPositionDeltaWrite instead of routing new rows to the data writer or the MoR writer's reinsert path.","commonSituations":"Custom Delta integrations or refactors that funnel both deletes and inserts through the delete writer; internal API misuse when writing MERGE results manually.","solutions":["Route inserted rows to the data writer (SparkWrite) rather than the position-delete writer.","Use the MoR writer's reinsert()/insert() path when operating in merge-on-read mode.","Upgrade Spark/Iceberg versions so the Delta execution plan routes inserts to the correct writer.","If implementing a custom writer, override insert() with real logic."],"exampleFix":"// before: insert on delete writer\npositionDeleteWriter.insert(row);\n// after: delegate to the data writer\ndataWriter.write(row);","handlingStrategy":"type-guard","validationCode":"if (!(writer instanceof RowDataWriter)) { throw new IllegalArgumentException(\"Route inserts to the data writer\"); }","typeGuard":"boolean acceptsInsert(Object w) { return w instanceof IcebergWriter && !(w instanceof PositionDeleteWriter); }","tryCatchPattern":"try { writer.insert(row); } catch (UnsupportedOperationException e) {\n  dataWriter.write(row); // route to the data writer\n}","preventionTips":["Send inserted rows to the data writer, deletes to the position-delete writer","Use reinsert() only on the MoR writer path","Do not bypass Spark's Delta execution routing"],"tags":["spark","row-level-operations","writer-api"],"backgroundTag":"method-not-implemented","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}