apache/iceberg · error · UnsupportedOperationException

Updating statistics is not supported by + getClass().getName

Error message

Updating statistics is not supported by + getClass().getName()

What it means

The default Table.updateStatistics() implementation throws UnsupportedOperationException to indicate the concrete table implementation cannot add or remove table-level statistics files. Implementations must override this method to support statistics updates; the message names the offending class so developers can see which implementation lacks support.

Source

Thrown at api/src/main/java/org/apache/iceberg/Table.java:298

   * @return a new {@link ReplacePartitions}
   */
  ReplacePartitions newReplacePartitions();

  /**
   * Create a new {@link DeleteFiles delete API} to delete files in this table and commit.
   *
   * @return a new {@link DeleteFiles}
   */
  DeleteFiles newDelete();

  /**
   * Create a new {@link UpdateStatistics update table statistics API} to add or remove statistics
   * files in this table.
   *
   * @return a new {@link UpdateStatistics}
   */
  default UpdateStatistics updateStatistics() {
    throw new UnsupportedOperationException(
        "Updating statistics is not supported by " + getClass().getName());
  }

  /**
   * Create a new {@link UpdatePartitionStatistics update partition statistics API} to add or remove
   * partition statistics files in this table.
   *
   * @return a new {@link UpdatePartitionStatistics}
   */
  default UpdatePartitionStatistics updatePartitionStatistics() {
    throw new UnsupportedOperationException(
        "Updating partition statistics is not supported by " + getClass().getName());
  }

  /**
   * Create a new {@link ExpireSnapshots expire API} to expire snapshots in this table and commit.
   *
   * @return a new {@link ExpireSnapshots}

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Ensure you operate on the real (Base)Table, not a metadata table or wrapper, before calling updateStatistics().
  2. Upgrade to an Iceberg catalog implementation that supports UpdateStatistics.
  3. Catch UnsupportedOperationException and degrade to skipping the statistics update.
  4. If implementing a custom Table, override updateStatistics() to return a real UpdateStatistics implementation.

Example fix

// before
table.updateStatistics().addStatisticsFile(statsFile).commit();

// after
if (!(table instanceof SupportsStatistics)) { // or check concrete type
  throw new IllegalStateException("Table " + table.name() + " cannot update statistics");
}
table.updateStatistics().addStatisticsFile(statsFile).commit();
Defensive patterns

Strategy: try-catch

Validate before calling

// check table is a real data table before updating statistics
if (table.getClass().getName().contains("MetadataTable")) {
  throw new IllegalStateException("Cannot update statistics on a metadata table");
}

Type guard

boolean supportsStatisticsUpdate(Table t) {
  try { t.updateStatistics(); return true; }
  catch (UnsupportedOperationException e) { return false; }
}

Try / catch

try {
  table.updateStatistics().addStatisticsFile(f).commit();
} catch (UnsupportedOperationException e) {
  LOG.warn("Statistics update unsupported by {}", e.getMessage());
}

Prevention

When it happens

Trigger: Calling table.updateStatistics() (directly or via commitStats or ExpireSnapshots-related statistics removal paths) on a Table implementation that does not override it — metadata tables, custom/wrapped Table objects, or older catalog implementations.

Common situations: Writing Apache Datasketch column-statistics files via a catalog whose Table doesn't support statistics; running test scaffolding or maintenance tools against metadata-table views; using a custom Table wrapper that forwards most operations but not statistics updates.

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/6142a9d7c4d04655. Report an issue: GitHub.