{"record":{"id":"3fbeff88efe59bd5","repo":"apache/iceberg","slug":"renaming-a-view-is-not-supported-by-catalog-cat-3fbeff","errorCode":null,"errorMessage":"Renaming a view is not supported by catalog: ${catalogName}","messagePattern":"Renaming a view is not supported by catalog: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/SparkSessionCatalog.java","lineNumber":538,"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":520,"sourceCodeEnd":543,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/SparkSessionCatalog.java#L520-L543","documentation":"Thrown by SparkSessionCatalog.renameView when no underlying catalog supports view renaming: the source view does not resolve to a view-capable catalog and the session catalog is not a view catalog. ALTER VIEW ... RENAME TO cannot be performed.","triggerScenarios":"Executing ALTER VIEW ... RENAME TO where fromIdentifier is not found in any registered view catalog and the session catalog lacks ViewCatalog support.","commonSituations":"Renaming views against legacy catalogs without view support; source view name typo so the view-capable branch never executes.","solutions":["Point the rename at a catalog with view support by fully qualifying the source identifier.","Recreate the view under the new name (CREATE VIEW new AS SELECT from old) then drop the old one.","Configure a ViewCatalog-capable delegate for the session catalog."],"exampleFix":"// before\nALTER VIEW spark_catalog.db.old_v RENAME TO db.new_v  // unsupported\n// after\nCREATE VIEW spark_catalog.db.new_v AS SELECT * FROM spark_catalog.db.old_v;\nDROP VIEW spark_catalog.db.old_v","handlingStrategy":"type-guard","validationCode":"if (!catalog.viewExists(fromIdentifier)) { throw new IllegalStateException(\"cannot rename missing view: \" + fromIdentifier); }","typeGuard":"boolean canRenameView(Catalog catalog, Identifier from) { return catalog instanceof ViewCatalog && ((ViewCatalog) catalog).viewExists(from); }","tryCatchPattern":"try { catalog.renameView(from, to); } catch (UnsupportedOperationException e) { /* create-new + drop-old fallback */ }","preventionTips":["Rename only views that resolve in a view-capable catalog.","Use a create-then-drop migration pattern when rename is unsupported.","Qualify the source identifier with the correct catalog."],"tags":["spark","views","unsupported-operation","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"}