apache/iceberg · error · UnsupportedOperationException

Cannot update partition statistics of a

Error message

Cannot update partition statistics of a %s table

What it means

Partition statistics updates are also write operations; BaseReadOnlyTable rejects them with UnsupportedOperationException. Partition statistics files can only be committed against a real, writable table metadata.

Solutions

  1. Load the live table from the catalog and call updatePartitionStatistics() there.
  2. Feature-check the handle before publishing partition statistics.
  3. Route statistics publication through a Transaction created from the writable table.

Example fix

// before
readOnlyTable.updatePartitionStatistics().setPartitionStatisticsCommit(psFile).commit();
// after
Table table = catalog.loadTable(tableIdentifier);
table.updatePartitionStatistics().setPartitionStatisticsCommit(psFile).commit();
Defensive patterns

Strategy: validation

Validate before calling

if (!(table instanceof BaseReadOnlyTable)) {
  table.updatePartitionStatistics().setPartitionStatisticsCommit(psFile).commit();
}

Type guard

boolean supportsPartitionStats(Table t) { return !(t instanceof BaseReadOnlyTable); }

Try / catch

try { table.updatePartitionStatistics()...commit(); } catch (UnsupportedOperationException e) { /* skip or reload writable table */ }

Prevention

When it happens

Trigger: Calling table.updatePartitionStatistics() on a read-only table wrapper (snapshot or metadata-backed table).

Common situations: Jobs that compute and publish partition-level statistics being pointed at a snapshot handle; generic table-maintenance utilities.

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

Appendix: source

Thrown at core/src/main/java/org/apache/iceberg/BaseReadOnlyTable.java:105

  public ReplacePartitions newReplacePartitions() {
    throw new UnsupportedOperationException(
        "Cannot replace partitions in a " + descriptor + " table");
  }

  @Override
  public DeleteFiles newDelete() {
    throw new UnsupportedOperationException("Cannot delete from a " + descriptor + " table");
  }

  @Override
  public UpdateStatistics updateStatistics() {
    throw new UnsupportedOperationException(
        "Cannot update statistics of a " + descriptor + " table");
  }

  @Override
  public UpdatePartitionStatistics updatePartitionStatistics() {
    throw new UnsupportedOperationException(
        "Cannot update partition statistics of a " + descriptor + " table");
  }

  @Override
  public ExpireSnapshots expireSnapshots() {
    throw new UnsupportedOperationException(
        "Cannot expire snapshots from a " + descriptor + " table");
  }

  @Override
  public ManageSnapshots manageSnapshots() {
    throw new UnsupportedOperationException(
        "Cannot manage snapshots in a " + descriptor + " table");
  }

  @Override
  public Transaction newTransaction() {
    throw new UnsupportedOperationException(

View on GitHub (pinned to 86d9c8fc54)