{"record":{"id":"7ba3159bce84e8fc","repo":"apache/iceberg","slug":"replacing-a-view-is-not-supported-by-catalog-ca","errorCode":null,"errorMessage":"Replacing a view is not supported by catalog: ${catalogName}","messagePattern":"Replacing 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":688,"sourceCode":"        org.apache.iceberg.view.View view =\n            asViewCatalog\n                .buildView(buildIdentifier(ident))\n                .withDefaultCatalog(currentCatalog)\n                .withDefaultNamespace(Namespace.of(currentNamespace))\n                .withQuery(\"spark\", sql)\n                .withSchema(icebergSchema)\n                .withLocation(properties.get(\"location\"))\n                .withProperties(props)\n                .createOrReplace();\n        return new SparkView(catalogName, view);\n      } catch (org.apache.iceberg.exceptions.NoSuchNamespaceException e) {\n        throw new NoSuchNamespaceException(currentNamespace);\n      } catch (org.apache.iceberg.exceptions.NoSuchViewException e) {\n        throw new NoSuchViewException(ident);\n      }\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) {\n      try {\n        org.apache.iceberg.view.View view = asViewCatalog.loadView(buildIdentifier(ident));\n        UpdateViewProperties updateViewProperties = view.updateProperties();\n\n        for (ViewChange change : changes) {\n          if (change instanceof ViewChange.SetProperty) {\n            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;","sourceCodeStart":670,"sourceCodeEnd":706,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java#L670-L706","documentation":"SparkCatalog throws this from replaceView when the underlying Iceberg catalog does not implement the ViewCatalog interface (asViewCatalog is null). The SQL REPLACE VIEW statement cannot be executed because view replacement is a catalog capability, and the configured catalog only supports tables. It signals a catalog capability gap, not a problem with the view itself.","triggerScenarios":"Executing 'CREATE OR REPLACE VIEW' or 'REPLACE VIEW' through Spark SQL when the session catalog (e.g. HadoopCatalog, JDBC without view support, or a REST catalog lacking view support) does not implement ViewCatalog.","commonSituations":"Upgrading Spark/Iceberg against an older catalog backend that predates view support; configuring a custom catalog implementation that only extends TableCatalog; running REPLACE VIEW in tests against HadoopCatalog which lacks view support.","solutions":["Use a catalog that implements org.apache.iceberg.catalog.ViewCatalog (REST catalog, HiveCatalog, JDBC catalog, Nessie) in spark.sql.catalog.<name>.","Drop and recreate the view manually instead of REPLACE VIEW.","If you control the catalog implementation, extend ViewCatalog and implement replaceView."],"exampleFix":"// before\nspark.conf.set(\"spark.sql.catalog.local\", \"org.apache.iceberg.spark.SparkCatalog\")\nspark.conf.set(\"spark.sql.catalog.local.catalog-impl\", HADOOP_CATALOG)\n// after\nspark.conf.set(\"spark.sql.catalog.local.catalog-impl\", \"org.apache.iceberg.rest.RESTCatalog\") // ViewCatalog-capable backend","handlingStrategy":"validation","validationCode":"// before issuing REPLACE VIEW\nif (!(catalogRef instanceof org.apache.iceberg.catalog.ViewCatalog)) {\n  throw new IllegalStateException(\"Catalog does not support views; REPLACE VIEW unavailable\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check catalog capability (instanceof ViewCatalog) before issuing view DDL.","Configure ViewCatalog-capable backends for workloads that use views.","Document per-environment catalog capabilities."],"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"}