{"record":{"id":"87b66a2e24738e42","repo":"apache/iceberg","slug":"cannot-rename-s-to-s-table-does-not-exist","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":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/inmemory/InMemoryCatalog.java","lineNumber":178,"sourceCode":"        .sorted(Comparator.comparing(TableIdentifier::toString))\n        .collect(Collectors.toList());\n  }\n\n  @Override\n  public void renameTable(TableIdentifier from, TableIdentifier to) {\n    if (from.equals(to)) {\n      return;\n    }\n\n    synchronized (this) {\n      if (!namespaceExists(to.namespace())) {\n        throw new NoSuchNamespaceException(\n            \"Cannot rename %s to %s. Namespace does not exist: %s\", from, to, to.namespace());\n      }\n\n      String fromLocation = tables.get(from);\n      if (null == fromLocation) {\n        throw new NoSuchTableException(\"Cannot rename %s to %s. Table does not exist\", from, to);\n      }\n\n      if (tables.containsKey(to)) {\n        throw new AlreadyExistsException(\"Cannot rename %s to %s. Table already exists\", from, to);\n      }\n\n      if (views.containsKey(to)) {\n        throw new AlreadyExistsException(\"Cannot rename %s to %s. View already exists\", from, to);\n      }\n\n      tables.put(to, fromLocation);\n      tables.remove(from);\n    }\n  }\n\n  @Override\n  public void createNamespace(Namespace namespace) {\n    createNamespace(namespace, Collections.emptyMap());","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/inmemory/InMemoryCatalog.java#L160-L196","documentation":"InMemoryCatalog.renameTable throws NoSuchTableException when the source table does not exist under 'from'. The rename reads the from entry from the internal tables map; a null location means no such table.","triggerScenarios":"Calling catalog.renameTable(from, to) where from was never registered or was already dropped. Also when 'from' names a view rather than a table (views are stored separately).","commonSituations":"Renaming a table twice (second call fails); renaming a view via renameTable instead of the view API; case or namespace mismatch in the source identifier.","solutions":["Verify the source exists via tableExists(from) before renaming","Use the correct identifier including full namespace","If it is a view, use the view rename path, not renameTable","Catch NoSuchTableException to skip missing sources idempotently"],"exampleFix":"// before\ncatalog.renameTable(TableIdentifier.of(\"ns\",\"evnts\"), to);\n// after\nTableIdentifier from = TableIdentifier.of(\"ns\",\"events\");\nif (catalog.tableExists(from)) {\n  catalog.renameTable(from, to);\n}","handlingStrategy":"validation","validationCode":"if (!catalog.tableExists(from)) { throw new IllegalStateException(\"Source table missing: \" + from); }","typeGuard":null,"tryCatchPattern":"try { catalog.renameTable(from, to); } catch (NoSuchTableException e) { log.warn(\"Skip rename, source missing: {}\", from); }","preventionTips":["Check tableExists(from) before rename","Distinguish tables from views; use the right rename API","Use full TableIdentifier with correct namespace","Avoid double-renames in retry logic by making steps idempotent"],"tags":["inmemory-catalog","rename","no-such-table"],"backgroundTag":"resource-not-found","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}