{"record":{"id":"199e73ced5113920","repo":"apache/iceberg","slug":"cannot-rename-s-to-s-view-does-not-exist-199e73","errorCode":null,"errorMessage":"Cannot rename %s to %s. View does not exist","messagePattern":"Cannot rename (.+?) to (.+?)\\. View does not exist","errorType":"exception","errorClass":"NoSuchViewException","httpStatus":404,"severity":"error","filePath":"hive-metastore/src/main/java/org/apache/iceberg/hive/HiveCatalog.java","lineNumber":437,"sourceCode":"      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);\n    }\n  }","sourceCodeStart":419,"sourceCodeEnd":455,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/hive-metastore/src/main/java/org/apache/iceberg/hive/HiveCatalog.java#L419-L455","documentation":"Thrown by HiveCatalog.renameTableOrView when the Hive Metastore reports NoSuchObjectException during a view rename, meaning the source view does not exist. Iceberg translates this into NoSuchViewException, mirroring the table case. The rename was aborted because there is no view to move.","triggerScenarios":"Calling HiveCatalog.renameView(from, to) where 'from' is not an existing Iceberg view in the metastore, or the identifier points to a table rather than a view.","commonSituations":"Renaming a view that was already dropped; passing a table identifier to renameView; typo or wrong namespace in the view name; metastore where the Iceberg view metadata was never created.","solutions":["Confirm the view exists with catalog.viewExists(from) before renaming.","Verify the identifier is a view, not a table; use renameTable for tables.","Check the metastore connection/environment and exact view name casing."],"exampleFix":"// before\ncatalog.renameView(from, to);\n// after\nif (catalog.viewExists(from)) {\n  catalog.renameView(from, to);\n}","handlingStrategy":"validation","validationCode":"if (!catalog.viewExists(from)) { throw new IllegalArgumentException(\"Source view \" + from + \" does not exist\"); }","typeGuard":null,"tryCatchPattern":"try { catalog.renameView(from, to); } catch (org.apache.iceberg.exceptions.NoSuchViewException e) { LOG.error(\"Rename skipped: view {} not found\", from, e); }","preventionTips":["Check viewExists(from) before renaming views","Use renameTable for tables and renameView for views","Verify identifier casing against listViews(namespace)"],"tags":["hive-metastore","rename","view-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"}