{"record":{"id":"d274a87c013e7fbf","repo":"apache/iceberg","slug":"cannot-update-partition-statistics-of-a-s-table","errorCode":null,"errorMessage":"Cannot update partition statistics of a %s table","messagePattern":"Cannot update partition statistics of a (.+?) table","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/BaseReadOnlyTable.java","lineNumber":105,"sourceCode":"  public ReplacePartitions newReplacePartitions() {\n    throw new UnsupportedOperationException(\n        \"Cannot replace partitions in a \" + descriptor + \" table\");\n  }\n\n  @Override\n  public DeleteFiles newDelete() {\n    throw new UnsupportedOperationException(\"Cannot delete from a \" + descriptor + \" table\");\n  }\n\n  @Override\n  public UpdateStatistics updateStatistics() {\n    throw new UnsupportedOperationException(\n        \"Cannot update statistics of a \" + descriptor + \" table\");\n  }\n\n  @Override\n  public UpdatePartitionStatistics updatePartitionStatistics() {\n    throw new UnsupportedOperationException(\n        \"Cannot update partition statistics of a \" + descriptor + \" table\");\n  }\n\n  @Override\n  public ExpireSnapshots expireSnapshots() {\n    throw new UnsupportedOperationException(\n        \"Cannot expire snapshots from a \" + descriptor + \" table\");\n  }\n\n  @Override\n  public ManageSnapshots manageSnapshots() {\n    throw new UnsupportedOperationException(\n        \"Cannot manage snapshots in a \" + descriptor + \" table\");\n  }\n\n  @Override\n  public Transaction newTransaction() {\n    throw new UnsupportedOperationException(","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/BaseReadOnlyTable.java#L87-L123","documentation":"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.","triggerScenarios":"Calling table.updatePartitionStatistics() on a read-only table wrapper (snapshot or metadata-backed table).","commonSituations":"Jobs that compute and publish partition-level statistics being pointed at a snapshot handle; generic table-maintenance utilities.","solutions":["Load the live table from the catalog and call updatePartitionStatistics() there.","Feature-check the handle before publishing partition statistics.","Route statistics publication through a Transaction created from the writable table."],"exampleFix":"// before\nreadOnlyTable.updatePartitionStatistics().setPartitionStatisticsCommit(psFile).commit();\n// after\nTable table = catalog.loadTable(tableIdentifier);\ntable.updatePartitionStatistics().setPartitionStatisticsCommit(psFile).commit();","handlingStrategy":"validation","validationCode":"if (!(table instanceof BaseReadOnlyTable)) {\n  table.updatePartitionStatistics().setPartitionStatisticsCommit(psFile).commit();\n}","typeGuard":"boolean supportsPartitionStats(Table t) { return !(t instanceof BaseReadOnlyTable); }","tryCatchPattern":"try { table.updatePartitionStatistics()...commit(); } catch (UnsupportedOperationException e) { /* skip or reload writable table */ }","preventionTips":["Verify handle writability before partition-stats publication","Resolve snapshot handles back to their parent table for writes"],"tags":["unsupported-operation","read-only-table","partition-statistics"],"backgroundTag":"unsupported-operation","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}