{"record":{"id":"2bac5272ed42792e","repo":"apache/iceberg","slug":"renaming-a-view-is-not-supported-by-catalog-catal-2bac52","errorCode":null,"errorMessage":"Renaming a view is not supported by catalog: catalogName","messagePattern":"Renaming a view is not supported by catalog: catalogName","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/SparkSessionCatalog.java","lineNumber":561,"sourceCode":"  public boolean dropView(Identifier ident) {\n    if (null != asViewCatalog && asViewCatalog.viewExists(ident)) {\n      return asViewCatalog.dropView(ident);\n    } else if (isViewCatalog()) {\n      return getSessionCatalog().dropView(ident);\n    }\n\n    return false;\n  }\n\n  @Override\n  public void renameView(Identifier fromIdentifier, Identifier toIdentifier)\n      throws NoSuchViewException, ViewAlreadyExistsException {\n    if (null != asViewCatalog && asViewCatalog.viewExists(fromIdentifier)) {\n      asViewCatalog.renameView(fromIdentifier, toIdentifier);\n    } else if (isViewCatalog()) {\n      getSessionCatalog().renameView(fromIdentifier, toIdentifier);\n    } else {\n      throw new UnsupportedOperationException(\n          \"Renaming a view is not supported by catalog: \" + catalogName);\n    }\n  }\n}\n","sourceCodeStart":543,"sourceCodeEnd":566,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/SparkSessionCatalog.java#L543-L566","documentation":"SparkSessionCatalog.renameView renames a view through a delegate view catalog when one exists, or the session view catalog if this catalog is itself a view catalog. With neither available, it throws this UnsupportedOperationException, indicating the catalog for catalogName cannot manage views at all.","triggerScenarios":"Calling renameView(fromIdentifier, toIdentifier) (e.g. ALTER VIEW ... RENAME TO ...) when asViewCatalog is null or does not contain the source view and isViewCatalog() is false.","commonSituations":"Renaming views in catalogs lacking ViewCatalog support; confusion between table and view namespaces; migrating to a catalog version that predates Iceberg view support (views only exist since Iceberg 1.4).","solutions":["Point the catalog at a ViewCatalog implementation so rename is delegated correctly.","Recreate the view under the new name manually: CREATE VIEW new AS <query>; DROP VIEW old;","Upgrade Iceberg if the target catalog supports views but the bundled Spark runtime version predates view support."],"exampleFix":"// before\nspark.sql(\"ALTER VIEW old_view RENAME TO new_view\") // throws\n// after\nspark.sql(\"CREATE VIEW new_view AS SELECT * FROM old_view\")\nspark.sql(\"DROP VIEW old_view\")","handlingStrategy":"try-catch","validationCode":"ViewCatalog vc = ((SparkCatalog) sparkCatalog).asViewCatalog();\nif (vc == null) { /* rename unsupported: recreate under new name */ }","typeGuard":"boolean supportsRenameView = sparkCatalog instanceof ViewCatalog\n    || (sparkCatalog instanceof SparkCatalog && ((SparkCatalog) sparkCatalog).asViewCatalog() != null);","tryCatchPattern":"try {\n  catalog.renameView(from, to);\n} catch (UnsupportedOperationException e) {\n  if (e.getMessage().contains(\"Renaming a view\")) { /* fallback: create to; drop from */ }\n  else throw e;\n}","preventionTips":["Avoid ALTER VIEW RENAME workflows on catalogs without view support.","Document view capabilities per catalog in your platform config.","Prefer catalogs with ViewCatalog (Iceberg 1.4+ backends) for view lifecycle operations."],"tags":["unsupported-operation","view","rename","catalog"],"backgroundTag":"unsupported-operation","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"}