{"record":{"id":"f134daf88e587b2a","repo":"apache/iceberg","slug":"cannot-call-commit-on-temporary-table-operations","errorCode":null,"errorMessage":"Cannot call commit on temporary table operations","messagePattern":"Cannot call commit on temporary table operations","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/BaseMetastoreTableOperations.java","lineNumber":254,"sourceCode":"  }\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());\n      }\n\n      @Override\n      public FileIO io() {\n        return BaseMetastoreTableOperations.this.io();\n      }","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/BaseMetastoreTableOperations.java#L236-L272","documentation":"TemporaryTableOperations cannot persist anything: it wraps uncommitted metadata with no metastore backing. Its commit() override throws UnsupportedOperationException so callers cannot mistakenly treat staged/uncommitted metadata as a durable commit. Use the owning catalog or real TableOperations to persist changes.","triggerScenarios":"Calling commit(base, metadata) on temporary operations from transaction staging (e.g., staged create/replace flows); trying to 'save' staged metadata directly instead of completing the transaction.","commonSituations":"Misunderstanding staged transaction APIs and attempting to commit via the temporary ops handle; utility code shared between normal and staged flows; attempting to persist an uncommitted metadata tree during a dry-run.","solutions":["Complete the staged transaction through the catalog API (e.g., commit the transaction or create from staged metadata) rather than calling commit on temporary ops","Use catalog.buildTable(...).createTransaction()/createOrReplaceTransaction() and commit the Transaction object","Route persistence through a metastore-backed TableOperations instance"],"exampleFix":"// before\ntempOps.commit(base, metadata); // UnsupportedOperationException\n// after\nTransaction tx = catalog.buildTable(ident, schema).createTransaction();\n// ... apply changes via tx ...\ntx.commitTransaction(); // persists through the real catalog","handlingStrategy":"type-guard","validationCode":"if (isTemporaryOps(ops)) { throw new IllegalStateException(\"Use the catalog/Transaction to persist changes\"); } else { ops.commit(base, metadata); }","typeGuard":"boolean isTemporaryOps(TableOperations ops) { return ops instanceof BaseMetastoreTableOperations && !supportsRealCommit; /* flag set when temporary ops are created */ }","tryCatchPattern":"try { ops.commit(base, metadata); }\ncatch (UnsupportedOperationException e) { /* temporary ops: persist via Transaction.commitTransaction() instead */ }","preventionTips":["Never persist through temporary operations handles","Always use Transaction APIs for staged changes","Keep staged (dry-run) and committed flows in separate code paths"],"tags":["unsupported-operation","temporary-table","commit"],"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"}