{"record":{"id":"f6893f85fd91c253","repo":"apache/iceberg","slug":"s-does-not-implement-addfile","errorCode":null,"errorMessage":"%s does not implement addFile","messagePattern":"(.+?) does not implement addFile","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"api/src/main/java/org/apache/iceberg/RewriteFiles.java","lineNumber":81,"sourceCode":"   * @return this for method chaining\n   */\n  default RewriteFiles deleteFile(DeleteFile deleteFile) {\n    throw new UnsupportedOperationException(\n        this.getClass().getName() + \" does not implement deleteFile\");\n  }\n\n  /**\n   * Add a new data file.\n   *\n   * <p>This rewrite operation may change the size or layout of the data files. When applicable, it\n   * is also recommended to discard already deleted records while rewriting data files. However, the\n   * set of live data records must never change.\n   *\n   * @param dataFile a new data file\n   * @return this for method chaining\n   */\n  default RewriteFiles addFile(DataFile dataFile) {\n    throw new UnsupportedOperationException(\n        this.getClass().getName() + \" does not implement addFile\");\n  }\n\n  /**\n   * Add a new delete file.\n   *\n   * <p>This rewrite operation may change the size or layout of the delete files. When applicable,\n   * it is also recommended to discard delete records for files that are no longer part of the table\n   * state. However, the set of applicable delete records must never change.\n   *\n   * @param deleteFile a new delete file\n   * @return this for method chaining\n   */\n  default RewriteFiles addFile(DeleteFile deleteFile) {\n    throw new UnsupportedOperationException(\n        this.getClass().getName() + \" does not implement addFile\");\n  }\n","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/api/src/main/java/org/apache/iceberg/RewriteFiles.java#L63-L99","documentation":"RewriteFiles.addFile(DataFile) is a default interface method that throws UnsupportedOperationException when an implementation does not override it. Rewriting data files requires the operation to record replacement files; this default signals the implementation in use does not implement the add half of the rewrite contract.","triggerScenarios":"Calling addFile(DataFile) on a RewriteFiles instance that is not the standard BaseRewriteFiles — e.g. a stub/test double, a catalog-supplied wrapper, or code path (makeRewriteDataFiles, doReplace) wired to an implementation lacking the method.","commonSituations":"Custom table operation classes in unit tests; mixed api/core versions where the core module predates the current RewriteFiles surface; third-party catalogs returning custom SnapshotProducer implementations.","solutions":["Use the standard RewriteFiles from table.newRewrite(), which is implemented by BaseRewriteFiles with addFile(DataFile) support.","Align the api and core Iceberg artifact versions on the classpath so the implementation overrides all addFile overloads.","If you implement RewriteFiles yourself, override addFile(DataFile) to record the new data file."],"exampleFix":"// before\nRewriteFiles rewrite = (RewriteFiles) Proxy.newProxyInstance(...); // partial stub\nrewrite.addFile(newFile); // UnsupportedOperationException\n// after\nRewriteFiles rewrite = table.newRewrite();\nrewrite.addFile(newFile);","handlingStrategy":"try-catch","validationCode":"Preconditions.checkArgument(!(rewrite instanceof UnsupportedOperationExceptionThrowingStub), \"use table.newRewrite()\");","typeGuard":"static boolean supportsAddDataFile(RewriteFiles rf) { return rf instanceof BaseRewriteFiles; }","tryCatchPattern":"try {\n  rewrite.addFile(newDataFile);\n} catch (UnsupportedOperationException e) {\n  throw new IllegalStateException(\"This RewriteFiles does not implement addFile(DataFile)\", e);\n}","preventionTips":["Use the stock RewriteFiles from table.newRewrite().","Avoid partial test doubles for SnapshotProducer types outside unit tests.","Verify api/core version alignment on the classpath."],"tags":["java","iceberg","api-contract","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-14T11:17:12.474Z"}