apache/iceberg · error · UnsupportedOperationException

Cannot call commit on temporary table operations

Error message

Cannot call commit on temporary table operations

What it means

The temporary TableOperations inner class in HiveTableOperations also rejects commit(base, metadata) with UnsupportedOperationException, because it exists only to carry uncommitted metadata and file-location resolution, not to perform actual commits. Any code path committing through it violates its contract.

Source

Thrown at hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java:474

  }

  @Override
  public TableOperations temp(TableMetadata uncommittedMetadata) {
    return new TableOperations() {
      @Override
      public TableMetadata current() {
        return uncommittedMetadata;
      }

      @Override
      public TableMetadata refresh() {
        throw new UnsupportedOperationException(
            "Cannot call refresh on temporary table operations");
      }

      @Override
      public void commit(TableMetadata base, TableMetadata metadata) {
        throw new UnsupportedOperationException("Cannot call commit on temporary table operations");
      }

      @Override
      public String metadataFileLocation(String fileName) {
        return HiveTableOperations.this.metadataFileLocation(uncommittedMetadata, fileName);
      }

      @Override
      public LocationProvider locationProvider() {
        return LocationProviders.locationsFor(
            uncommittedMetadata.location(), uncommittedMetadata.properties());
      }

      @Override
      public FileIO io() {
        HiveTableOperations.this.encryptionPropsFromMetadata(uncommittedMetadata.properties());
        return HiveTableOperations.this.io();
      }

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Commit through a normally loaded Table (catalog.loadTable(...).newXxx().commit()) instead of the temporary operations object
  2. If updating Hive-level properties, use the appropriate catalog/Hive client APIs rather than table operations commit
  3. Refactor code that captures the temp operations so it only reads metadata locations, never commits

Example fix

// before
tempOperations.commit(base, metadata); // UnsupportedOperationException
// after
Table table = catalog.loadTable(tableIdent);
table.newAppend().appendFile(file).commit();
Defensive patterns

Strategy: type-guard

Validate before calling

if (!(table.operations() instanceof HiveTableOperations)) {
  throw new IllegalStateException("This table does not support direct commits");
}

Type guard

boolean supportsCommit(Table table) {
  return table.operations() instanceof HiveTableOperations;
}

Try / catch

try {
  table.newAppend().appendFile(f).commit();
} catch (UnsupportedOperationException e) {
  // table was built on temporary operations; reload from catalog
  table = catalog.loadTable(ident);
  table.newAppend().appendFile(f).commit();
}

Prevention

When it happens

Trigger: Calling commit(...) on the temporary operations instance — e.g. application code that built a Table view over temporary operations and invokes newAppend()/newReplace...commit(), or tests asserting the guard.

Common situations: Misuse of HiveCatalog internals; wrapping a temp-operations-backed Table and treating it as a writable table; tests verifying unsupported behavior.

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/74fe92df6bb20f5b. Report an issue: GitHub.