{"record":{"id":"6136ef437132ad59","repo":"apache/iceberg","slug":"cannot-call-refresh-on-temporary-table-operations-6136ef","errorCode":null,"errorMessage":"Cannot call refresh on temporary table operations","messagePattern":"Cannot call refresh on temporary table operations","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java","lineNumber":468,"sourceCode":"    return TableType.EXTERNAL_TABLE;\n  }\n\n  @Override\n  public ClientPool<IMetaStoreClient, TException> metaClients() {\n    return metaClients;\n  }\n\n  @Override\n  public TableOperations temp(TableMetadata uncommittedMetadata) {\n    return new TableOperations() {\n      @Override\n      public TableMetadata current() {\n        return uncommittedMetadata;\n      }\n\n      @Override\n      public TableMetadata refresh() {\n        throw new UnsupportedOperationException(\n            \"Cannot call refresh on temporary table operations\");\n      }\n\n      @Override\n      public void commit(TableMetadata base, TableMetadata metadata) {\n        throw new UnsupportedOperationException(\"Cannot call commit on temporary table operations\");\n      }\n\n      @Override\n      public String metadataFileLocation(String fileName) {\n        return HiveTableOperations.this.metadataFileLocation(uncommittedMetadata, fileName);\n      }\n\n      @Override\n      public LocationProvider locationProvider() {\n        return LocationProviders.locationsFor(\n            uncommittedMetadata.location(), uncommittedMetadata.properties());\n      }","sourceCodeStart":450,"sourceCodeEnd":486,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java#L450-L486","documentation":"HiveTableOperations contains an inner temporary TableOperations used for committing metadata produced outside normal refresh/commit flow (e.g. Hive metadata updates in HiveCatalog). Refresh is intentionally unsupported there and throws UnsupportedOperationException. This is an internal-invariant error: a caller invoked an operation that has no meaning for this ephemeral object.","triggerScenarios":"Calling refresh() (directly or via Table.refresh()) on the temporary table operations instance returned/used by Hive metadata-handling paths; tests exercise it via the temporary operations object.","commonSituations":"Application code that obtained a Table backed by temporary operations and calls refresh(); framework code reusing HiveCatalog internals incorrectly; tests verifying the unsupported behavior.","solutions":["Load a fresh Table from the catalog instead of refreshing the temporary operations-backed table","Use the real HiveTableOperations-backed Table (catalog.loadTable) for refresh semantics","Do not call refresh/commit on internal temporary operations objects; only use their metadataFileLocation/metadata helpers"],"exampleFix":"// before\ntempOperations.refresh(); // UnsupportedOperationException\n// after\nTable fresh = catalog.loadTable(tableIdent);\nfresh.refresh();","handlingStrategy":"type-guard","validationCode":"if (ops instanceof HiveTableOperations) { /* refresh is safe */ } else { load fresh table from catalog }","typeGuard":"boolean supportsRefresh(TableOperations ops) {\n  return ops instanceof HiveTableOperations;\n}","tryCatchPattern":"try {\n  table.refresh();\n} catch (UnsupportedOperationException e) {\n  table = catalog.loadTable(ident); // reload instead\n}","preventionTips":["Never call refresh/commit on internal temporary operations objects","Only mutate tables loaded from a catalog","Guard with instanceof HiveTableOperations before refresh","Keep framework code away from HiveCatalog internals"],"tags":["unsupported-operation","hive-catalog","internal-api"],"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"}