{"record":{"id":"9af0ec9e96a69139","repo":"apache/iceberg","slug":"this-getclass-getname-doesn-t-implement-uu","errorCode":null,"errorMessage":"this.getClass().getName() + \" doesn't implement uuid\"","messagePattern":"this\\.getClass\\(\\)\\.getName\\(\\) \\+ \" doesn't implement uuid\"","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"api/src/main/java/org/apache/iceberg/Table.java","lineNumber":372,"sourceCode":"  /** Returns the current partition statistics files for the table. */\n  default List<PartitionStatisticsFile> partitionStatisticsFiles() {\n    return ImmutableList.of();\n  }\n\n  /**\n   * Returns the current refs for the table\n   *\n   * @return the current refs for the table\n   */\n  Map<String, SnapshotRef> refs();\n\n  /**\n   * Returns the UUID of the table\n   *\n   * @return the UUID of the table\n   */\n  default UUID uuid() {\n    throw new UnsupportedOperationException(this.getClass().getName() + \" doesn't implement uuid\");\n  }\n\n  /**\n   * Returns the snapshot referenced by the given name or null if no such reference exists.\n   *\n   * @return the snapshot which is referenced by the given name or null if no such reference exists.\n   */\n  default Snapshot snapshot(String name) {\n    SnapshotRef ref = refs().get(name);\n    if (ref != null) {\n      return snapshot(ref.snapshotId());\n    }\n\n    return null;\n  }\n}\n","sourceCodeStart":354,"sourceCodeEnd":389,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/api/src/main/java/org/apache/iceberg/Table.java#L354-L389","documentation":"The default Table.uuid() implementation throws UnsupportedOperationException with the class name appended, because not every Table implementation carries a stable table UUID. Implementations backed by real table metadata (BaseTable) return the metadata's table-uuid; wrappers, metadata tables, and stubs leave the default throwing version.","triggerScenarios":"Calling table.uuid() on a Table that doesn't override uuid() — e.g. SerializableTable delegates, scan-planning paths (planTableScan), metadata-table UUID lookups, or custom Table implementations created in tests (commitToTable, testCompleteCreateTable).","commonSituations":"Code that identifies tables by UUID across catalogs or serializes table identity; scan planning utilities assuming UUID availability; tests using in-memory table implementations without UUID support.","solutions":["Only call uuid() on tables backed by real metadata; otherwise read the UUID from table.metadata() or fall back to the table name.","Catch UnsupportedOperationException and use table.name() or another identity as a fallback key.","Upgrade or unwrap the Table implementation to one that exposes the metadata UUID.","Override uuid() in custom Table implementations to return the metadata table UUID."],"exampleFix":"// before\nString id = table.uuid();\n\n// after\nString id;\ntry {\n  id = table.uuid();\n} catch (UnsupportedOperationException e) {\n  id = table.name(); // fallback identity for implementations without UUID\n}","handlingStrategy":"fallback","validationCode":"// resolve a stable identity without assuming uuid()\nString identity;\ntry { identity = table.uuid(); } catch (UnsupportedOperationException e) { identity = table.name(); }","typeGuard":"String tableIdOrName(Table t) {\n  try { return t.uuid(); }\n  catch (UnsupportedOperationException e) { return t.name(); }\n}","tryCatchPattern":"String id;\ntry {\n  id = table.uuid();\n} catch (UnsupportedOperationException e) {\n  id = table.name(); // implementations without metadata-backed UUID\n}","preventionTips":["Treat uuid() as an optional capability; always provide a name-based fallback","Avoid persisting table identity keyed solely on uuid() for arbitrary Table implementations","Override uuid() in custom Table implementations backed by TableMetadata"],"tags":["unsupported-operation","table-uuid","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"}