{"record":{"id":"17317d682bc5edfc","repo":"apache/iceberg","slug":"cannot-rename-s-to-s-table-does-not-exist-17317d","errorCode":null,"errorMessage":"Cannot rename %s to %s. Table does not exist","messagePattern":"Cannot rename (.+?) to (.+?)\\. Table does not exist","errorType":"exception","errorClass":"NoSuchTableException","httpStatus":404,"severity":"error","filePath":"hive-metastore/src/main/java/org/apache/iceberg/hive/HiveCatalog.java","lineNumber":435,"sourceCode":"    try {\n      Table table = clients.run(client -> client.getTable(fromDatabase, fromName));\n      validateTableIsIcebergTableOrView(contentType, table, CatalogUtil.fullTableName(name, from));\n\n      table.setDbName(toDatabase);\n      table.setTableName(to.name());\n\n      clients.run(\n          client -> {\n            MetastoreUtil.alterTable(client, fromDatabase, fromName, table);\n            return null;\n          });\n\n      LOG.info(\"Renamed {} from {}, to {}\", contentType.value(), from, to);\n\n    } catch (NoSuchObjectException e) {\n      switch (contentType) {\n        case TABLE:\n          throw new NoSuchTableException(\"Cannot rename %s to %s. Table does not exist\", from, to);\n        case VIEW:\n          throw new NoSuchViewException(\"Cannot rename %s to %s. View does not exist\", from, to);\n      }\n\n    } catch (InvalidOperationException e) {\n      if (e.getMessage() != null\n          && e.getMessage().contains(String.format(\"new table %s already exists\", to))) {\n        throw new AlreadyExistsException(\"Table already exists: %s\", to);\n      } else {\n        throw new RuntimeException(\"Failed to rename \" + from + \" to \" + to, e);\n      }\n\n    } catch (TException e) {\n      throw new RuntimeException(\"Failed to rename \" + from + \" to \" + to, e);\n\n    } catch (InterruptedException e) {\n      Thread.currentThread().interrupt();\n      throw new RuntimeException(\"Interrupted in call to rename\", e);","sourceCodeStart":417,"sourceCodeEnd":453,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/hive-metastore/src/main/java/org/apache/iceberg/hive/HiveCatalog.java#L417-L453","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before\ncatalog.renameTable(from, to);\n// after\nif (catalog.tableExists(from)) {\n  catalog.renameTable(from, to);\n} else {\n  LOG.warn(\"Skipping rename; source table {} does not exist\", from);\n}","handlingStrategy":"validation","validationCode":"if (!catalog.tableExists(from)) { throw new IllegalArgumentException(\"Source table \" + from + \" does not exist\"); }","typeGuard":null,"tryCatchPattern":"try { catalog.renameTable(from, to); } catch (org.apache.iceberg.exceptions.NoSuchTableException e) { LOG.error(\"Rename skipped: {} not found\", from, e); }","preventionTips":["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"],"tags":["hive-metastore","rename","table-not-found","catalog"],"backgroundTag":"entity-not-found","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"}