{"record":{"id":"8906d9d62505155b","repo":"apache/iceberg","slug":"renaming-a-view-is-not-supported-by-catalog-cat-8906d9","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.1/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java","lineNumber":763,"sourceCode":"      return asViewCatalog.dropView(buildIdentifier(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) {\n      try {\n        asViewCatalog.renameView(buildIdentifier(fromIdentifier), buildIdentifier(toIdentifier));\n      } catch (org.apache.iceberg.exceptions.NoSuchViewException e) {\n        throw new NoSuchViewException(fromIdentifier);\n      } catch (org.apache.iceberg.exceptions.AlreadyExistsException e) {\n        throw new ViewAlreadyExistsException(toIdentifier);\n      }\n    } else {\n      throw new UnsupportedOperationException(\n          \"Renaming a view is not supported by catalog: \" + catalogName);\n    }\n  }\n\n  @Override\n  public final void initialize(String name, CaseInsensitiveStringMap options) {\n    super.initialize(name, options);\n\n    boolean cacheEnabled =\n        PropertyUtil.propertyAsBoolean(\n            options, CatalogProperties.CACHE_ENABLED, CatalogProperties.CACHE_ENABLED_DEFAULT);\n\n    boolean cacheCaseSensitive =\n        PropertyUtil.propertyAsBoolean(\n            options,\n            CatalogProperties.CACHE_CASE_SENSITIVE,\n            CatalogProperties.CACHE_CASE_SENSITIVE_DEFAULT);\n","sourceCodeStart":745,"sourceCodeEnd":781,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java#L745-L781","documentation":"SparkCatalog delegates view operations to an underlying Iceberg catalog only when that catalog implements the ViewCatalog interface (asViewCatalog). renameView() throws this UnsupportedOperationException when the configured catalog does not support views, so rename cannot be performed at all. It is a capability error, not a data or state error: the catalog backend (e.g. HadoopCatalog or an older custom catalog) simply has no view registry.","triggerScenarios":"Calling ALTER VIEW ... RENAME TO (or SparkCatalog.renameView(fromIdentifier, toIdentifier)) on a catalog whose underlying Iceberg catalog is not a ViewCatalog. In initialize(), asViewCatalog stays null for such catalogs, so line 763 is always hit for any renameView call.","commonSituations":"Using spark.sql.catalog.<name>=org.apache.iceberg.hive.HiveCatalog or another implementation without ViewCatalog support, or an older Iceberg catalog version that predates view support, then running ALTER VIEW my_view RENAME TO new_name.","solutions":["Check whether the underlying catalog supports views: it must implement org.apache.iceberg.view.ViewCatalog (e.g. HiveCatalog, RESTCatalog, JDBC catalog with a views table); switch to a catalog implementation that does.","If the catalog supports views, verify the catalog configuration (spark.sql.catalog.<name>) actually points to the view-capable implementation rather than a fallback like HadoopTables/HadoopCatalog.","Work around by drop + create: DROP VIEW old_name; CREATE VIEW new_name AS <query> (accepting that lineage of the view definition is rebuilt manually).","Upgrade Iceberg if the backend (e.g. older REST server) does not yet expose view endpoints."],"exampleFix":"// before (unsupported catalog)\nALTER VIEW iceberg_catalog.db.v RENAME TO iceberg_catalog.db.v2;\n\n// after: use a view-capable catalog\nspark.conf.set(\"spark.sql.catalog.rest\", \"org.apache.iceberg.spark.SparkCatalog\");\nspark.conf.set(\"spark.sql.catalog.rest.catalog-impl\", \"org.apache.iceberg.rest.RESTCatalog\");\nALTER VIEW rest.db.v RENAME TO rest.db.v2;","handlingStrategy":"validation","validationCode":"Catalog iceberg = /* resolved SparkCatalog's underlying catalog */;\nif (!(iceberg instanceof org.apache.iceberg.view.ViewCatalog)) {\n  throw new IllegalStateException(\"Catalog \" + name + \" does not support views; ALTER VIEW RENAME unavailable\");\n}","typeGuard":"boolean supportsViews = org.apache.iceberg.catalog.Catalog.class.isInstance(iceberg)\n    && iceberg instanceof org.apache.iceberg.view.ViewCatalog;","tryCatchPattern":"try {\n  spark.sql(\"ALTER VIEW \" + name + \" RENAME TO \" + newName);\n} catch (UnsupportedOperationException e) {\n  if (e.getMessage().contains(\"Renaming a view is not supported\")) {\n    // fall back to drop+create or switch catalog\n  } else {\n    throw e;\n  }\n}","preventionTips":["Pick a ViewCatalog-backed implementation (HiveCatalog, RESTCatalog, JDBC with view tables) when views are required.","Assert catalog capability at session setup: `sparkCatalog.icebergCatalog() instanceof ViewCatalog`.","Keep Iceberg version >= view support for your chosen backend."],"tags":["spark","iceberg","unsupported-operation","views","catalog"],"backgroundTag":"operation-not-supported","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}