{"record":{"id":"fe223f0691fbc7f8","repo":"apache/iceberg","slug":"replacing-a-view-is-not-supported-by-catalog","errorCode":null,"errorMessage":"Replacing a view is not supported by catalog: ","messagePattern":"Replacing 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":543,"sourceCode":"      String[] columnAliases,\n      String[] columnComments,\n      Map<String, String> properties)\n      throws NoSuchNamespaceException, NoSuchViewException {\n    if (asViewCatalog instanceof SupportsReplaceView) {\n      return ((SupportsReplaceView) asViewCatalog)\n          .replaceView(\n              ident,\n              sql,\n              currentCatalog,\n              currentNamespace,\n              schema,\n              queryColumnNames,\n              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) {","sourceCodeStart":525,"sourceCodeEnd":561,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/SparkSessionCatalog.java#L525-L561","documentation":"replaceView in SparkSessionCatalog throws UnsupportedOperationException when neither the delegate view catalog nor the session catalog supports view replacement. This is the view counterpart of CREATE OR REPLACE and is only proxied when the underlying catalog implements ViewCatalog.","triggerScenarios":"Executing CREATE OR REPLACE VIEW on a catalog with no ViewCatalog delegate; the view exists only in a non-view-capable catalog so no branch handles the replace.","commonSituations":"CI pipelines replacing views against a catalog that never supported views; misconfigured catalog name causing resolution against the wrong, view-less catalog; pre-3.3 Spark sessions lacking view APIs.","solutions":["Use DROP VIEW then CREATE VIEW against a view-capable catalog, or add a view-capable delegate","Point the operation at a catalog that implements ViewCatalog (e.g. Iceberg REST catalog with view support)","Rewrite the SQL to use ALTER VIEW ... AS SELECT where the engine supports it"],"exampleFix":"// before\nspark.sql(\"CREATE OR REPLACE VIEW iceberg.db.v AS SELECT ...\"); // unsupported here\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 supportsViews(Catalog c) { return c instanceof ViewCatalog; }","tryCatchPattern":"try {\n  catalog.replaceView(...);\n} catch (UnsupportedOperationException e) {\n  // DROP VIEW + CREATE VIEW fallback\n}","preventionTips":["Prefer DROP/CREATE over CREATE OR REPLACE VIEW when view support is uncertain","Standardize view management on a single view-capable catalog"],"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"}