apache/iceberg · error · NoSuchTableException
Cannot rename %s to %s. Table does not exist
Error message
Cannot rename %s to %s. Table does not exist
What it means
Thrown by HiveCatalog.renameTableOrView when the Hive Metastore reports NoSuchObjectException during a table rename, meaning the source table does not exist in the metastore. Iceberg translates this Thrift error into the catalog API's NoSuchTableException so callers can use standard catalog error handling. It signals the rename was never attempted against a real table.
Source
Thrown at hive-metastore/src/main/java/org/apache/iceberg/hive/HiveCatalog.java:435
try {
Table table = clients.run(client -> client.getTable(fromDatabase, fromName));
validateTableIsIcebergTableOrView(contentType, table, CatalogUtil.fullTableName(name, from));
table.setDbName(toDatabase);
table.setTableName(to.name());
clients.run(
client -> {
MetastoreUtil.alterTable(client, fromDatabase, fromName, table);
return null;
});
LOG.info("Renamed {} from {}, to {}", contentType.value(), from, to);
} catch (NoSuchObjectException e) {
switch (contentType) {
case TABLE:
throw new NoSuchTableException("Cannot rename %s to %s. Table does not exist", from, to);
case VIEW:
throw new NoSuchViewException("Cannot rename %s to %s. View does not exist", from, to);
}
} catch (InvalidOperationException e) {
if (e.getMessage() != null
&& e.getMessage().contains(String.format("new table %s already exists", to))) {
throw new AlreadyExistsException("Table already exists: %s", to);
} else {
throw new RuntimeException("Failed to rename " + from + " to " + to, e);
}
} catch (TException e) {
throw new RuntimeException("Failed to rename " + from + " to " + to, e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException("Interrupted in call to rename", e);View on GitHub (pinned to 86d9c8fc54)
Solutions
- Verify the source table exists: run catalog.tableExists(from) or list tables in the namespace before renaming.
- Check you are connected to the intended Hive Metastore (check hive-conf/metastore URIs) and that the namespace spelling and case match.
- Look for concurrent jobs that may have dropped the table; re-create or restore it if it was deleted unintentionally.
Example fix
// before
catalog.renameTable(from, to);
// after
if (catalog.tableExists(from)) {
catalog.renameTable(from, to);
} else {
LOG.warn("Skipping rename; source table {} does not exist", from);
} Defensive patterns
Strategy: validation
Validate before calling
if (!catalog.tableExists(from)) { throw new IllegalArgumentException("Source table " + from + " does not exist"); } Try / catch
try { catalog.renameTable(from, to); } catch (org.apache.iceberg.exceptions.NoSuchTableException e) { LOG.error("Rename skipped: {} not found", from, e); } Prevention
- Always check tableExists(from) before renaming
- Use catalog.listTables(namespace) to confirm exact identifiers
- Watch for concurrent DROP TABLE jobs
- Confirm the correct metastore environment via config
When it happens
Trigger: Calling HiveCatalog.renameTable(from, to) where 'from' is not an existing Iceberg table in the Hive Metastore (wrong namespace, typo in table name, or table dropped by another process before the rename).
Common situations: Typos in fully-qualified table names; running renames against a different metastore/environment than expected (dev vs prod); a concurrent DROP TABLE racing the rename; case-sensitivity mismatch in database or table name.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- Cannot rename table %s to %s: %s does not exist
- Cannot rename %s to %s. Namespace does not exist: %s
- Cannot rename %s to %s. View does not exist
- Table does not exist: %s
- NoSuchTableException(from)
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/17317d682bc5edfc.
Report an issue: GitHub.