{"record":{"id":"48e9e8aa22e968ec","repo":"apache/iceberg","slug":"s-does-not-implement-deletefile","errorCode":null,"errorMessage":"%s does not implement deleteFile","messagePattern":"(.+?) does not implement deleteFile","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"api/src/main/java/org/apache/iceberg/RewriteFiles.java","lineNumber":51,"sourceCode":" * If any of the deleted files are no longer in the latest snapshot when reattempting, the commit\n * will throw a {@link ValidationException}.\n *\n * <p>Note that the new state of the table after each rewrite must be logically equivalent to the\n * original table state.\n */\npublic interface RewriteFiles extends SnapshotUpdate<RewriteFiles> {\n  /**\n   * Remove a data file from the current table state.\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 rewritten data file\n   * @return this for method chaining\n   */\n  default RewriteFiles deleteFile(DataFile dataFile) {\n    throw new UnsupportedOperationException(\n        this.getClass().getName() + \" does not implement deleteFile\");\n  }\n\n  /**\n   * Remove a delete file from the table state.\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 rewritten delete file\n   * @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","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/api/src/main/java/org/apache/iceberg/RewriteFiles.java#L33-L69","documentation":"RewriteFiles.deleteFile(DataFile) is a default interface method on the api module's RewriteFiles contract that throws UnsupportedOperationException. The default exists so implementations are not forced to support it; the concrete operation class (e.g. BaseRewriteFiles) is expected to override it. Seeing this message means the RewriteFiles instance in hand is a subclass that did not implement the data-file removal half of the rewrite contract.","triggerScenarios":"Calling table.newRewrite() (or a RewriteFiles instance obtained from a custom/catalog-specific implementation) and invoking deleteFile(DataFile) when the implementation class only overrides the DeleteFile variants and not this method.","commonSituations":"A custom SnapshotProducer/RewriteFiles implementation (or a third-party catalog returning its own RewriteFiles) predates the v2 data-file rewrite API; engine or utility code calling deleteFile against an implementation compiled against an older Iceberg version where the method did not exist.","solutions":["Upgrade to an Iceberg implementation that overrides deleteFile(DataFile) (BaseRewriteFiles in iceberg-core implements it); ensure the runtime iceberg-core version matches the api version.","Verify the RewriteFiles instance comes from table.newRewrite() on a standard Iceberg table, not a wrapper returned by a custom catalog or test stub.","If you own a RewriteFiles implementation, override deleteFile(DataFile) to record the file for removal in the commit."],"exampleFix":"// before\nRewriteFiles rewrite = new MyMinimalRewriteFiles(); // custom impl without deleteFile(DataFile)\nrewrite.deleteFile(dataFile); // UnsupportedOperationException\n// after\nRewriteFiles rewrite = table.newRewrite(); // BaseRewriteFiles implements deleteFile\nrewrite.deleteFile(dataFile);","handlingStrategy":"try-catch","validationCode":"if (rewrite.getClass().getName().startsWith(\"org.apache.iceberg.\")) { /* BaseRewriteFiles implements deleteFile(DataFile) */ }","typeGuard":"static boolean supportsDataFileDelete(RewriteFiles rf) { return rf instanceof BaseRewriteFiles; }","tryCatchPattern":"try {\n  rewrite.deleteFile(dataFile);\n} catch (UnsupportedOperationException e) {\n  throw new IllegalStateException(\"RewriteFiles impl \" + rewrite.getClass() + \" cannot delete data files; upgrade iceberg-core\", e);\n}","preventionTips":["Always obtain RewriteFiles from table.newRewrite() on standard Iceberg tables.","Keep api and core Iceberg artifacts at identical versions.","Never rely on custom RewriteFiles stubs in production code paths."],"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"}