{"record":{"id":"4b91b6c19f7df936","repo":"apache/iceberg","slug":"altering-a-view-is-not-supported-by-catalog-cat-4b91b6","errorCode":null,"errorMessage":"Altering a view is not supported by catalog: ${catalogName}","messagePattern":"Altering 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":724,"sourceCode":"            ViewChange.SetProperty property = (ViewChange.SetProperty) change;\n            verifyNonReservedPropertyIsSet(property.property());\n            updateViewProperties.set(property.property(), property.value());\n          } else if (change instanceof ViewChange.RemoveProperty) {\n            ViewChange.RemoveProperty remove = (ViewChange.RemoveProperty) change;\n            verifyNonReservedPropertyIsUnset(remove.property());\n            updateViewProperties.remove(remove.property());\n          }\n        }\n\n        updateViewProperties.commit();\n\n        return new SparkView(catalogName, view);\n      } catch (org.apache.iceberg.exceptions.NoSuchViewException e) {\n        throw new NoSuchViewException(ident);\n      }\n    }\n\n    throw new UnsupportedOperationException(\n        \"Altering a view is not supported by catalog: \" + catalogName);\n  }\n\n  private static void verifyNonReservedProperty(String property, String errorMsg) {\n    if (SparkView.RESERVED_PROPERTIES.contains(property)) {\n      throw new UnsupportedOperationException(String.format(errorMsg, property));\n    }\n  }\n\n  private static void verifyNonReservedPropertyIsUnset(String property) {\n    verifyNonReservedProperty(property, \"Cannot unset reserved property: '%s'\");\n  }\n\n  private static void verifyNonReservedPropertyIsSet(String property) {\n    verifyNonReservedProperty(property, \"Cannot set reserved property: '%s'\");\n  }\n\n  @Override","sourceCodeStart":706,"sourceCodeEnd":742,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java#L706-L742","documentation":"alterView() only works when the underlying catalog implements the ViewCatalog interface (asViewCatalog != null). If the configured catalog only supports tables (e.g. a catalog without view support), SparkCatalog throws this UnsupportedOperationException. The catalog implementation itself, not your SQL, lacks view-alteration capability.","triggerScenarios":"Calling SparkCatalog.alterView(ident, changes...) when the initialized catalog does not implement org.apache.iceberg.catalog.ViewCatalog, so asViewCatalog is null.","commonSituations":"Configuring a catalog type that predates view support (e.g. older HadoopCatalog-style setups or third-party catalogs without ViewCatalog); running a newer Spark Iceberg runtime against an older catalog implementation; ALTER VIEW against a custom catalog plugin.","solutions":["Switch the affected namespaces to a catalog implementation that supports views (HiveCatalog, JDBC catalog, REST catalog, Nessie, etc.) with a current Iceberg version","Check the catalog class configured via spark.sql.catalog.<name> and confirm it implements ViewCatalog","If view properties must change elsewhere, manage the view outside Spark or migrate the view to a view-capable catalog"],"exampleFix":"// before\nspark.conf.set(\"spark.sql.catalog.local\", \"org.apache.iceberg.spark.SparkCatalog\");\nspark.conf.set(\"spark.sql.catalog.local.catalog-impl\", \"com.example.LegacyTableOnlyCatalog\");\n// after\nspark.conf.set(\"spark.sql.catalog.local.catalog-impl\", \"org.apache.iceberg.jdbc.JdbcCatalog\");","handlingStrategy":"type-guard","validationCode":"// Verify the catalog supports views before invoking view DDL\nCatalog plugin = spark.sessionState().catalogManager().catalog(name).asCatalog();\nif (!(plugin instanceof org.apache.spark.sql.connector.catalog.ViewCatalog)) {\n  throw new IllegalStateException(\"Catalog \" + name + \" does not support views\");\n}","typeGuard":"boolean supportsViews(Object catalogImpl) {\n  return catalogImpl instanceof org.apache.iceberg.catalog.ViewCatalog;\n}","tryCatchPattern":"try {\n  catalog.alterView(ident, changes);\n} catch (UnsupportedOperationException e) {\n  if (e.getMessage().contains(\"not supported by catalog\")) {\n    // fall back to a view-capable catalog or surface a clear user error\n  }\n}","preventionTips":["Confirm the catalog implementation class supports ViewCatalog before enabling view DDL for users","Use HiveCatalog, JdbcCatalog, REST catalog, or Nessie for workloads that need views","Align Iceberg runtime and catalog server versions so both sides support views"],"tags":["spark","view","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-23T08:17:48.524Z"}