{"record":{"id":"5e07f3f19a6daa4a","repo":"apache/iceberg","slug":"altering-a-view-is-not-supported-by-catalog-cat","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.0/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java","lineNumber":720,"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":702,"sourceCodeEnd":738,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java#L702-L738","documentation":"SparkCatalog throws this from alterView when the underlying catalog does not implement ViewCatalog (asViewCatalog is null). View alteration is a catalog-level capability, so without a ViewCatalog backend, any ALTER VIEW statement fails with this UnsupportedOperationException.","triggerScenarios":"Running 'ALTER VIEW name SET TBLPROPERTIES ...' or calling alterView() when the configured catalog implements only TableCatalog, e.g. HadoopCatalog or a custom catalog without view support.","commonSituations":"Using HadoopCatalog-backed Spark sessions; third-party catalog plugins predating view support; users unaware that view DDL requires a ViewCatalog-capable backend.","solutions":["Configure a catalog implementing ViewCatalog (REST, Hive, JDBC, Nessie).","Drop and recreate the view with updated definition/properties.","Set view properties via a supported engine/catalog once ViewCatalog is enabled."],"exampleFix":"// before\nspark.conf.set(\"spark.sql.catalog.local.catalog-impl\", \"org.apache.iceberg.hadoop.HadoopCatalog\")\nspark.sql(\"ALTER VIEW v SET TBLPROPERTIES ('k'='v')\") // throws\n// after\nspark.conf.set(\"spark.sql.catalog.local.catalog-impl\", \"org.apache.iceberg.rest.RESTCatalog\")\nspark.sql(\"ALTER VIEW v SET TBLPROPERTIES ('k'='v')\")","handlingStrategy":"validation","validationCode":"if (!(catalogRef instanceof org.apache.iceberg.catalog.ViewCatalog)) {\n  throw new IllegalStateException(\"ALTER VIEW requires a ViewCatalog-capable catalog\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer REST/Hive/JDBC/Nessie catalogs when view properties must be altered.","Avoid copying table TBLPROPERTIES workflows onto views without checking support.","Catch UnsupportedOperationException and fall back to drop/recreate."],"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-14T16:17:12.679Z"}