apache/iceberg · error · UnsupportedOperationException

Unsupported file content type: ${file.content()}

Error message

Unsupported file content type: ${file.content()}

What it means

SnapshotSummary.Builder.addedFile throws UnsupportedOperationException when a ContentFile whose content() is not DATA, POSITION_DELETES, or EQUALITY_DELETES is added to a snapshot summary. Iceberg's FileContent enum is closed, so any unknown value (e.g. from a newer spec or a corrupted/bespoke file implementation) cannot be summarized. It indicates the summary builder encountered a file content type it does not recognize.

Source

Thrown at core/src/main/java/org/apache/iceberg/SnapshotSummary.java:314

          this.addedRecords += file.recordCount();
          break;
        case POSITION_DELETES:
          DeleteFile deleteFile = (DeleteFile) file;
          if (ContentFileUtil.isDV(deleteFile)) {
            this.addedDVs += 1;
          } else {
            this.addedPosDeleteFiles += 1;
          }
          this.addedDeleteFiles += 1;
          this.addedPosDeletes += file.recordCount();
          break;
        case EQUALITY_DELETES:
          this.addedDeleteFiles += 1;
          this.addedEqDeleteFiles += 1;
          this.addedEqDeletes += file.recordCount();
          break;
        default:
          throw new UnsupportedOperationException(
              "Unsupported file content type: " + file.content());
      }
    }

    void removedFile(ContentFile<?> file) {
      this.removedSize += ScanTaskUtil.contentSizeInBytes(file);
      switch (file.content()) {
        case DATA:
          this.removedFiles += 1;
          this.deletedRecords += file.recordCount();
          break;
        case POSITION_DELETES:
          DeleteFile deleteFile = (DeleteFile) file;
          if (ContentFileUtil.isDV(deleteFile)) {
            this.removedDVs += 1;
          } else {
            this.removedPosDeleteFiles += 1;
          }

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Fix the ContentFile construction so content() returns a valid FileContent (FileContent.DATA for appends, FileContent.POSITION_DELETES or FileContent.EQUALITY_DELETES for delete files).
  2. If the file comes from serialized metadata, verify it was written by a compatible Iceberg version and re-write with a supported writer.
  3. If you implement a custom ContentFile wrapper, delegate content() to the wrapped file instead of returning a custom/unknown value.
  4. Check for null content(): pass through the correct typed interface (DataFile vs DeleteFile) rather than a generic ContentFile when appending.

Example fix

// before
ContentFile<?> file = new MockContentFile(); // content() returns null
appendFiles(table).appendFile(file);

// after
DataFile file = DataFiles.builder(table.spec())
    .withPath("/data/file.parquet")
    .withFileSizeInBytes(1024)
    .withRecordCount(10)
    .build(); // content() == FileContent.DATA
appendFiles(table).appendFile(file);
Defensive patterns

Strategy: validation

Validate before calling

// Java
if (file.content() == null ||
    (file.content() != FileContent.DATA &&
     file.content() != FileContent.POSITION_DELETES &&
     file.content() != FileContent.EQUALITY_DELETES)) {
  throw new IllegalArgumentException("Unexpected file content: " + file.content());
}

Type guard

// Java
boolean isKnownContent(ContentFile<?> f) {
  FileContent c = f.content();
  return c == FileContent.DATA
      || c == FileContent.POSITION_DELETES
      || c == FileContent.EQUALITY_DELETES;
}

Prevention

When it happens

Trigger: Calling appendFiles/overwriteFiles (which route through updatePartitions -> addedFile) with a ContentFile whose FileContent is a value outside the three known enum constants — typically a custom ContentFile implementation, an enum from a future spec version, or deserialization of a file with content=null.

Common situations: Custom catalog/FileIO integrations that hand-construct DataFile/DeleteFile objects with the wrong or unset content field; forward-compatibility issues when reading metadata produced by a newer Iceberg spec; test fixtures that mock ContentFile and return an unexpected content().

Related errors


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