{"record":{"id":"d48a8a1bd63d43dd","repo":"apache/iceberg","slug":"updating-partition-statistics-is-not-supported-by-d48a8a","errorCode":null,"errorMessage":"Updating partition statistics is not supported by + getClass().getName()","messagePattern":"Updating partition statistics is not supported by \\+ getClass\\(\\)\\.getName\\(\\)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"api/src/main/java/org/apache/iceberg/Transaction.java","lineNumber":158,"sourceCode":"  /**\n   * Create a new {@link UpdateStatistics update table statistics API} to add or remove statistics\n   * files in this table.\n   *\n   * @return a new {@link UpdateStatistics}\n   */\n  default UpdateStatistics updateStatistics() {\n    throw new UnsupportedOperationException(\n        \"Updating statistics is not supported by \" + getClass().getName());\n  }\n\n  /**\n   * Create a new {@link UpdatePartitionStatistics update partition statistics API} to add or remove\n   * partition statistics files in this table.\n   *\n   * @return a new {@link UpdatePartitionStatistics}\n   */\n  default UpdatePartitionStatistics updatePartitionStatistics() {\n    throw new UnsupportedOperationException(\n        \"Updating partition statistics is not supported by \" + getClass().getName());\n  }\n\n  /**\n   * Create a new {@link ExpireSnapshots expire API} to expire snapshots in this table.\n   *\n   * @return a new {@link ExpireSnapshots}\n   */\n  ExpireSnapshots expireSnapshots();\n\n  /**\n   * Create a new {@link ManageSnapshots manage snapshot API} to manage snapshots in this table.\n   *\n   * @return a new {@link ManageSnapshots}\n   */\n  default ManageSnapshots manageSnapshots() {\n    throw new UnsupportedOperationException(\n        \"Managing snapshots is not supported by \" + getClass().getName());","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/api/src/main/java/org/apache/iceberg/Transaction.java#L140-L176","documentation":"The default Transaction.updatePartitionStatistics() throws UnsupportedOperationException because not every Transaction implementation can stage partition-statistics file changes. Implementations must override it to support adding or removing partition statistics files within a transaction; the message names the class that does not.","triggerScenarios":"Calling transaction.updatePartitionStatistics() (e.g. commitPartitionStatsTxn / removePartitionStatsTxn flows) on a Transaction implementation that keeps the throwing default — transactions on tables/wrappers without partition statistics support.","commonSituations":"Atomically committing partition statistics alongside other metadata operations; tests or maintenance jobs applying partition stats through a generic transaction object rather than the table directly.","solutions":["Apply partition statistics updates directly via table.updatePartitionStatistics() instead of through the transaction.","Obtain the transaction from the real BaseTable so it overrides updatePartitionStatistics().","Catch UnsupportedOperationException and fall back to a standalone statistics commit.","Override updatePartitionStatistics() in custom Transaction implementations."],"exampleFix":"// before\nTransaction txn = table.newTransaction();\ntxn.updatePartitionStatistics().addPartitionStatisticsFile(file).commit();\ntxn.commitTransaction();\n\n// after\ntry {\n  Transaction txn = table.newTransaction();\n  txn.updatePartitionStatistics().addPartitionStatisticsFile(file).commit();\n  txn.commitTransaction();\n} catch (UnsupportedOperationException e) {\n  table.updatePartitionStatistics().addPartitionStatisticsFile(file).commit();\n}","handlingStrategy":"fallback","validationCode":"// probe support before staging partition statistics in the txn\ntry {\n  txn.updatePartitionStatistics();\n} catch (UnsupportedOperationException e) {\n  useDirectPartitionStatsUpdate(table);\n}","typeGuard":"boolean txnSupportsPartitionStats(Transaction txn) {\n  try { txn.updatePartitionStatistics(); return true; }\n  catch (UnsupportedOperationException e) { return false; }\n}","tryCatchPattern":"try {\n  txn.updatePartitionStatistics().addPartitionStatisticsFile(f).commit();\n} catch (UnsupportedOperationException e) {\n  table.updatePartitionStatistics().addPartitionStatisticsFile(f).commit();\n}","preventionTips":["Fall back to table.updatePartitionStatistics() when the transaction cannot stage partition stats","Verify the table implementation supports partition statistics before wrapping work in a transaction","Add partition-stats transaction tests to any custom Transaction implementation's suite"],"tags":["unsupported-operation","partition-statistics","transaction"],"backgroundTag":"unsupported-operation","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}