{"record":{"id":"6142a9d7c4d04655","repo":"apache/iceberg","slug":"updating-statistics-is-not-supported-by-getclass","errorCode":null,"errorMessage":"Updating statistics is not supported by + getClass().getName()","messagePattern":"Updating statistics is not supported by \\+ getClass\\(\\)\\.getName\\(\\)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"api/src/main/java/org/apache/iceberg/Table.java","lineNumber":298,"sourceCode":"   * @return a new {@link ReplacePartitions}\n   */\n  ReplacePartitions newReplacePartitions();\n\n  /**\n   * Create a new {@link DeleteFiles delete API} to delete files in this table and commit.\n   *\n   * @return a new {@link DeleteFiles}\n   */\n  DeleteFiles newDelete();\n\n  /**\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 and commit.\n   *\n   * @return a new {@link ExpireSnapshots}","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/api/src/main/java/org/apache/iceberg/Table.java#L280-L316","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure you operate on the real (Base)Table, not a metadata table or wrapper, before calling updateStatistics().","Upgrade to an Iceberg catalog implementation that supports UpdateStatistics.","Catch UnsupportedOperationException and degrade to skipping the statistics update.","If implementing a custom Table, override updateStatistics() to return a real UpdateStatistics implementation."],"exampleFix":"// before\ntable.updateStatistics().addStatisticsFile(statsFile).commit();\n\n// after\nif (!(table instanceof SupportsStatistics)) { // or check concrete type\n  throw new IllegalStateException(\"Table \" + table.name() + \" cannot update statistics\");\n}\ntable.updateStatistics().addStatisticsFile(statsFile).commit();","handlingStrategy":"try-catch","validationCode":"// check table is a real data table before updating statistics\nif (table.getClass().getName().contains(\"MetadataTable\")) {\n  throw new IllegalStateException(\"Cannot update statistics on a metadata table\");\n}","typeGuard":"boolean supportsStatisticsUpdate(Table t) {\n  try { t.updateStatistics(); return true; }\n  catch (UnsupportedOperationException e) { return false; }\n}","tryCatchPattern":"try {\n  table.updateStatistics().addStatisticsFile(f).commit();\n} catch (UnsupportedOperationException e) {\n  LOG.warn(\"Statistics update unsupported by {}\", e.getMessage());\n}","preventionTips":["Operate on the underlying BaseTable, not wrappers or metadata tables","Keep catalog implementations current — older ones lack UpdateStatistics support","Unit-test custom Table implementations against all Table default methods"],"tags":["unsupported-operation","statistics","api-default-method"],"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"}