{"record":{"id":"2c6b5517027d3b9a","repo":"apache/iceberg","slug":"altering-a-view-is-not-supported-by-catalog","errorCode":null,"errorMessage":"Altering a view is not supported by catalog: ","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/SparkSessionCatalog.java","lineNumber":556,"sourceCode":"              columnAliases,\n              columnComments,\n              properties);\n    }\n\n    throw new UnsupportedOperationException(\n        \"Replacing a view is not supported by catalog: \" + catalogName);\n  }\n\n  @Override\n  public View alterView(Identifier ident, ViewChange... changes)\n      throws NoSuchViewException, IllegalArgumentException {\n    if (null != asViewCatalog && asViewCatalog.viewExists(ident)) {\n      return asViewCatalog.alterView(ident, changes);\n    } else if (isViewCatalog()) {\n      return getSessionCatalog().alterView(ident, changes);\n    }\n\n    throw new UnsupportedOperationException(\n        \"Altering a view is not supported by catalog: \" + catalogName);\n  }\n\n  @Override\n  public boolean dropView(Identifier ident) {\n    if (null != asViewCatalog && asViewCatalog.viewExists(ident)) {\n      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    if (null != asViewCatalog && asViewCatalog.viewExists(fromIdentifier)) {","sourceCodeStart":538,"sourceCodeEnd":574,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/SparkSessionCatalog.java#L538-L574","documentation":"alterView in SparkSessionCatalog throws UnsupportedOperationException when no view-capable catalog exists to apply the ViewChange operations. View alteration is only supported when the delegate or session catalog implements ViewCatalog.","triggerScenarios":"Running ALTER VIEW ... SET TBLPROPERTIES / AS SELECT against a catalog whose delegate lacks ViewCatalog; asViewCatalog is null and isViewCatalog() is false.","commonSituations":"Altering views on legacy catalogs that never implemented view APIs; wrong catalog resolution sending ALTER VIEW to an Iceberg table-only catalog; tools that unconditionally emit ALTER VIEW.","solutions":["Register a view-capable catalog and run ALTER VIEW against it","Drop and recreate the view with the desired definition/properties in a supported catalog","Apply the change directly through the underlying metastore/catalog API"],"exampleFix":"// before\nspark.sql(\"ALTER VIEW iceberg.db.v AS SELECT ...\"); // no view support\n// after\nspark.sql(\"DROP VIEW IF EXISTS spark_catalog.db.v\");\nspark.sql(\"CREATE VIEW spark_catalog.db.v AS SELECT ...\");","handlingStrategy":"fallback","validationCode":null,"typeGuard":"boolean supportsViewAlter(Catalog c) { return c instanceof ViewCatalog; }","tryCatchPattern":"try {\n  catalog.alterView(ident, changes);\n} catch (UnsupportedOperationException e) {\n  // recreate the view with the new definition instead\n}","preventionTips":["Check catalog view capabilities before generating ALTER VIEW statements","Route view mutations to the catalog that owns the view"],"tags":["spark","catalog","view","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"}