{"record":{"id":"74fe92df6bb20f5b","repo":"apache/iceberg","slug":"cannot-call-commit-on-temporary-table-operations-74fe92","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":"hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java","lineNumber":474,"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 HiveTableOperations.this.metadataFileLocation(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        HiveTableOperations.this.encryptionPropsFromMetadata(uncommittedMetadata.properties());\n        return HiveTableOperations.this.io();\n      }","sourceCodeStart":456,"sourceCodeEnd":492,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java#L456-L492","documentation":"The temporary TableOperations inner class in HiveTableOperations also rejects commit(base, metadata) with UnsupportedOperationException, because it exists only to carry uncommitted metadata and file-location resolution, not to perform actual commits. Any code path committing through it violates its contract.","triggerScenarios":"Calling commit(...) on the temporary operations instance — e.g. application code that built a Table view over temporary operations and invokes newAppend()/newReplace...commit(), or tests asserting the guard.","commonSituations":"Misuse of HiveCatalog internals; wrapping a temp-operations-backed Table and treating it as a writable table; tests verifying unsupported behavior.","solutions":["Commit through a normally loaded Table (catalog.loadTable(...).newXxx().commit()) instead of the temporary operations object","If updating Hive-level properties, use the appropriate catalog/Hive client APIs rather than table operations commit","Refactor code that captures the temp operations so it only reads metadata locations, never commits"],"exampleFix":"// before\ntempOperations.commit(base, metadata); // UnsupportedOperationException\n// after\nTable table = catalog.loadTable(tableIdent);\ntable.newAppend().appendFile(file).commit();","handlingStrategy":"type-guard","validationCode":"if (!(table.operations() instanceof HiveTableOperations)) {\n  throw new IllegalStateException(\"This table does not support direct commits\");\n}","typeGuard":"boolean supportsCommit(Table table) {\n  return table.operations() instanceof HiveTableOperations;\n}","tryCatchPattern":"try {\n  table.newAppend().appendFile(f).commit();\n} catch (UnsupportedOperationException e) {\n  // table was built on temporary operations; reload from catalog\n  table = catalog.loadTable(ident);\n  table.newAppend().appendFile(f).commit();\n}","preventionTips":["Load writable tables only via catalog.loadTable","Do not persist or reuse temporary operations instances beyond their intended scope","Treat UnsupportedOperationException on TableOperations as a contract misuse, fix the call site","Write unit tests asserting read-only usage of temp-operations-backed tables"],"tags":["unsupported-operation","hive-catalog","internal-api","commit"],"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"}