{"record":{"id":"63425c4103408c68","repo":"apache/iceberg","slug":"altering-a-view-is-not-supported-by-catalog-catal","errorCode":null,"errorMessage":"Altering a view is not supported by catalog: catalogName","messagePattern":"Altering 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/SparkCatalog.java","lineNumber":721,"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":703,"sourceCodeEnd":739,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java#L703-L739","documentation":"SparkCatalog.alterView throws UnsupportedOperationException when the wrapped catalog does not implement the Iceberg ViewCatalog interface (asViewCatalog is null). Views (including their properties) cannot be altered by table-only catalogs, so the operation is rejected with the catalog name in the message.","triggerScenarios":"Executing ALTER VIEW ... SET/UNSET TBLPROPERTIES (routed to alterView at SparkCatalog.java:694) against a catalog configured without ViewCatalog support, e.g. spark.sql.catalog.<name>=org.apache.iceberg.hadoop.HadoopCatalog or a custom Catalog implementation.","commonSituations":"Governance scripts that set owner/description properties on all objects hitting a HadoopCatalog-backed session; view maintenance jobs copied from Hive-catalog setups; custom in-house catalogs lacking ViewCatalog.","solutions":["Use a view-capable catalog (HiveCatalog, JdbcCatalog, RESTCatalog, NessieCatalog) for spark.sql.catalog.<name>.","Move the view to a catalog that supports view properties before altering.","Store view metadata elsewhere (e.g. table properties on a backing table or an external metadata store) if a table-only catalog must be used.","Implement org.apache.iceberg.catalog.ViewCatalog in the custom catalog to support ALTER VIEW."],"exampleFix":"// before\nspark.conf.set(\"spark.sql.catalog.gov\", \"org.apache.iceberg.hadoop.HadoopCatalog\");\nspark.sql(\"ALTER VIEW gov.ns.v SET TBLPROPERTIES ('owner'='data-team')\"); // fails\n\n// after\nspark.conf.set(\"spark.sql.catalog.gov\", \"org.apache.iceberg.jdbc.JdbcCatalog\");\nspark.sql(\"ALTER VIEW gov.ns.v SET TBLPROPERTIES ('owner'='data-team')\");","handlingStrategy":"validation","validationCode":"Catalog catalog = Spark3Util.loadIcebergCatalog(spark, catalogName);\nif (!(catalog instanceof ViewCatalog)) {\n  throw new IllegalStateException(\"ALTER VIEW unsupported on catalog \" + catalogName);\n}","typeGuard":"boolean supportsViewAlter(Catalog catalog) {\n  return catalog instanceof org.apache.iceberg.catalog.ViewCatalog;\n}","tryCatchPattern":"try {\n  spark.sql(\"ALTER VIEW \" + ident + \" SET TBLPROPERTIES ('owner'='data-team')\");\n} catch (UnsupportedOperationException e) {\n  if (e.getMessage().contains(\"Altering a view is not supported\")) {\n    // move view to a view-capable catalog or record metadata elsewhere\n  }\n}","preventionTips":["Verify ViewCatalog support before running governance scripts that ALTER views.","Keep view objects in catalogs that support view properties (JDBC/REST/Hive/Nessie).","Gate metadata-management jobs on catalog capability checks.","For custom catalogs, implement ViewCatalog before enabling view workflows."],"tags":["spark","view-catalog","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-23T08:17:48.524Z"}