{"record":{"id":"9287663ca5da3a0b","repo":"apache/iceberg","slug":"cannot-call-refresh-on-temporary-table-operations","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":"core/src/main/java/org/apache/iceberg/BaseMetastoreTableOperations.java","lineNumber":248,"sourceCode":"    return metadataFileLocation(current(), filename);\n  }\n\n  @Override\n  public LocationProvider locationProvider() {\n    return LocationProviders.locationsFor(current().location(), current().properties());\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 BaseMetastoreTableOperations.this.metadataFileLocation(\n            uncommittedMetadata, fileName);\n      }\n\n      @Override\n      public LocationProvider locationProvider() {\n        return LocationProviders.locationsFor(\n            uncommittedMetadata.location(), uncommittedMetadata.properties());","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/BaseMetastoreTableOperations.java#L230-L266","documentation":"TemporaryTableOperations (the anonymous subclass returned for uncommitted transaction metadata) cannot reload state from a metastore because it only holds in-memory, uncommitted metadata. Its refresh() override therefore throws UnsupportedOperationException to make clear that refresh semantics do not apply to temporary operations.","triggerScenarios":"Calling refresh() on TableOperations obtained from a temporary/staged table (e.g., transaction staging APIs or uncommitted metadata snapshots); any code path that calls current() triggering an internal refresh request on temporary ops.","commonSituations":"Staged/branch-like transaction workflows (stageCreate-like usage) where code treats the temporary ops like normal table ops; utility code that unconditionally refreshes before reading; tests that mix real and temporary operations.","solutions":["Do not call refresh on temporary table operations; read uncommittedMetadata via current() instead","Commit the staged transaction through the real catalog first, then operate on the resulting table's operations","Restructure code to distinguish TableOperations from temporary/staged operations before refreshing"],"exampleFix":"// before\ntempOps.refresh(); // UnsupportedOperationException\nTableMetadata meta = tempOps.current();\n// after\nTableMetadata meta = tempOps.current(); // temporary ops already expose in-memory metadata\n// refresh only on real, metastore-backed TableOperations","handlingStrategy":"type-guard","validationCode":"if (isTemporaryOps(ops)) { readFromCurrentMetadata(ops); } else { ops.refresh(); }","typeGuard":"boolean isTemporaryOps(TableOperations ops) { return ops instanceof BaseMetastoreTableOperations temp && !supportsRealRefresh; /* or track a flag when constructing temporary ops */ }","tryCatchPattern":"try { ops.refresh(); }\ncatch (UnsupportedOperationException e) { /* temporary ops: use current() metadata instead */ }","preventionTips":["Track whether operations are temporary/staged and branch before refreshing","Read staged state via current() only","Commit staged work through the catalog before refreshing"],"tags":["unsupported-operation","temporary-table","transaction"],"backgroundTag":"operation-not-supported","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"}