{"record":{"id":"a9374fff51d50ac4","repo":"apache/iceberg","slug":"renaming-a-view-is-not-supported-by-catalog-cat-a9374f","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.2/spark/src/main/java/org/apache/iceberg/spark/SparkSessionCatalog.java","lineNumber":651,"sourceCode":"      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    checkTableNotExists(toIdentifier);\n\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  private void checkTableNotExists(Identifier ident) throws ViewAlreadyExistsException {\n    if (tableExists(ident)) {\n      throw new ViewAlreadyExistsException(ident);\n    }\n  }\n\n  private void checkViewNotExists(Identifier ident) throws TableAlreadyExistsException {\n    if (viewExists(ident)) {\n      throw new TableAlreadyExistsException(ident);\n    }\n  }\n}\n","sourceCodeStart":633,"sourceCodeEnd":668,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/SparkSessionCatalog.java#L633-L668","documentation":"renameView in SparkSessionCatalog only renames views when either an injected view catalog or the session catalog implements ViewCatalog. When neither does, it throws this UnsupportedOperationException. It means the catalog has no view namespace to perform the rename in.","triggerScenarios":"Calling catalog.renameView(fromIdentifier, toIdentifier) when asViewCatalog is null (or the view doesn't exist in it) and the session catalog is not a ViewCatalog.","commonSituations":"RENAME VIEW / ALTER VIEW RENAME TO SQL against a table-only Iceberg catalog; misconfigured catalog-impl lacking view support; confusion between Spark's built-in session catalog and the Iceberg catalog for view operations.","solutions":["Switch to a catalog implementation that supports views (Hive, JDBC, REST with view support)","Register an asViewCatalog ViewCatalog so renameView can be delegated","Rename the view manually in the view-capable catalog (DROP + CREATE with new name)","Avoid view DDL against this catalog entirely"],"exampleFix":"// before\nunsupportedCatalog.renameView(oldIdent, newIdent); // throws\n// after\nif (catalog instanceof ViewCatalog) {\n  ((ViewCatalog) catalog).renameView(oldIdent, newIdent);\n} else {\n  throw new IllegalStateException(\"Configure a ViewCatalog to rename views\");\n}","handlingStrategy":"type-guard","validationCode":"boolean canRename = catalog instanceof org.apache.iceberg.view.ViewCatalog;","typeGuard":"if (!(catalog instanceof org.apache.iceberg.view.ViewCatalog)) {\n  throw new IllegalStateException(\"renameView requires a ViewCatalog\");\n}","tryCatchPattern":"try {\n  catalog.renameView(fromIdent, toIdent);\n} catch (UnsupportedOperationException e) {\n  // fall back to drop+create in a view-capable catalog or surface a config error\n}","preventionTips":["Avoid ALTER VIEW RENAME against table-only catalogs","Configure Hive/JDBC/REST view-capable catalogs for view DDL","Include renameView in catalog integration checks","Prefer re-creating views in controlled pipelines instead of renames"],"tags":["spark","catalog","views","rename","unsupported-operation"],"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"}