apache/iceberg · error · UnsupportedOperationException
Cannot call refresh on temporary table operations
Error message
Cannot call refresh on temporary table operations
What it means
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.
Source
Thrown at hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java:468
return TableType.EXTERNAL_TABLE;
}
@Override
public ClientPool<IMetaStoreClient, TException> metaClients() {
return metaClients;
}
@Override
public TableOperations temp(TableMetadata uncommittedMetadata) {
return new TableOperations() {
@Override
public TableMetadata current() {
return uncommittedMetadata;
}
@Override
public TableMetadata refresh() {
throw new UnsupportedOperationException(
"Cannot call refresh on temporary table operations");
}
@Override
public void commit(TableMetadata base, TableMetadata metadata) {
throw new UnsupportedOperationException("Cannot call commit on temporary table operations");
}
@Override
public String metadataFileLocation(String fileName) {
return HiveTableOperations.this.metadataFileLocation(uncommittedMetadata, fileName);
}
@Override
public LocationProvider locationProvider() {
return LocationProviders.locationsFor(
uncommittedMetadata.location(), uncommittedMetadata.properties());
}View on GitHub (pinned to 86d9c8fc54)
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
Example fix
// before tempOperations.refresh(); // UnsupportedOperationException // after Table fresh = catalog.loadTable(tableIdent); fresh.refresh();
Defensive patterns
Strategy: type-guard
Validate before calling
if (ops instanceof HiveTableOperations) { /* refresh is safe */ } else { load fresh table from catalog } Type guard
boolean supportsRefresh(TableOperations ops) {
return ops instanceof HiveTableOperations;
} Try / catch
try {
table.refresh();
} catch (UnsupportedOperationException e) {
table = catalog.loadTable(ident); // reload instead
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Application code that obtained a Table backed by temporary operations and calls refresh(); framework code reusing HiveCatalog internals incorrectly; tests verifying the unsupported behavior.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Cannot call commit on temporary table operations
- %s doesn't implement copyWithStats
- %s doesn't implement validateFilesExist
- Can't retrieve values from an empty struct
- Can't modify an empty struct
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/6136ef437132ad59.
Report an issue: GitHub.