apache/iceberg · error · UnsupportedOperationException

%s does not implement deleteFile

Error message

%s does not implement deleteFile

What it means

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.

Source

Thrown at api/src/main/java/org/apache/iceberg/RewriteFiles.java:51

 * If any of the deleted files are no longer in the latest snapshot when reattempting, the commit
 * will throw a {@link ValidationException}.
 *
 * <p>Note that the new state of the table after each rewrite must be logically equivalent to the
 * original table state.
 */
public interface RewriteFiles extends SnapshotUpdate<RewriteFiles> {
  /**
   * Remove a data file from the current table state.
   *
   * <p>This rewrite operation may change the size or layout of the data files. When applicable, it
   * is also recommended to discard already deleted records while rewriting data files. However, the
   * set of live data records must never change.
   *
   * @param dataFile a rewritten data file
   * @return this for method chaining
   */
  default RewriteFiles deleteFile(DataFile dataFile) {
    throw new UnsupportedOperationException(
        this.getClass().getName() + " does not implement deleteFile");
  }

  /**
   * Remove a delete file from the table state.
   *
   * <p>This rewrite operation may change the size or layout of the delete files. When applicable,
   * it is also recommended to discard delete records for files that are no longer part of the table
   * state. However, the set of applicable delete records must never change.
   *
   * @param deleteFile a rewritten delete file
   * @return this for method chaining
   */
  default RewriteFiles deleteFile(DeleteFile deleteFile) {
    throw new UnsupportedOperationException(
        this.getClass().getName() + " does not implement deleteFile");
  }

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. 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.
  2. Verify the RewriteFiles instance comes from table.newRewrite() on a standard Iceberg table, not a wrapper returned by a custom catalog or test stub.
  3. If you own a RewriteFiles implementation, override deleteFile(DataFile) to record the file for removal in the commit.

Example fix

// before
RewriteFiles rewrite = new MyMinimalRewriteFiles(); // custom impl without deleteFile(DataFile)
rewrite.deleteFile(dataFile); // UnsupportedOperationException
// after
RewriteFiles rewrite = table.newRewrite(); // BaseRewriteFiles implements deleteFile
rewrite.deleteFile(dataFile);
Defensive patterns

Strategy: try-catch

Validate before calling

if (rewrite.getClass().getName().startsWith("org.apache.iceberg.")) { /* BaseRewriteFiles implements deleteFile(DataFile) */ }

Type guard

static boolean supportsDataFileDelete(RewriteFiles rf) { return rf instanceof BaseRewriteFiles; }

Try / catch

try {
  rewrite.deleteFile(dataFile);
} catch (UnsupportedOperationException e) {
  throw new IllegalStateException("RewriteFiles impl " + rewrite.getClass() + " cannot delete data files; upgrade iceberg-core", e);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/48e9e8aa22e968ec. Report an issue: GitHub.