{"record":{"id":"5903f3b93e41af2c","repo":"apache/iceberg","slug":"replacing-a-view-is-not-supported-by-catalog-ca-5903f3","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.1/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java","lineNumber":692,"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":674,"sourceCodeEnd":710,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java#L674-L710","documentation":"Thrown by SparkCatalog.replaceView when the catalog does not implement ViewCatalog (or the operation is otherwise unavailable). Iceberg signals that replacing views is not a supported operation for this catalog. It is a capability error and will occur for every replace attempt regardless of arguments.","triggerScenarios":"CREATE OR REPLACE VIEW or programmatic replaceView on a catalog lacking view support (asViewCatalog == null), e.g. SparkCatalog wrapping HadoopCatalog or a table-only custom catalog.","commonSituations":"Same configuration gap as view creation errors: table-only catalog plugins, wrong catalog-impl, environments where views were never part of the catalog's feature set.","solutions":["Point the catalog at a ViewCatalog-backed implementation (RESTCatalog, HiveCatalog, JdbcCatalog, Nessie)","Drop and re-create the view via the table path if views are impossible, or store the definition externally","Verify spark.sql.catalog.<name>.catalog-impl settings","Upgrade Iceberg Spark runtime if the backing catalog gained view support in a newer version"],"exampleFix":"// before\nspark.sql(\"CREATE OR REPLACE VIEW prod.db.v AS SELECT ...\") // Replacing a view is not supported by catalog: prod\n// after\nspark.conf.set(\"spark.sql.catalog.prod.catalog-impl\", \"org.apache.iceberg.jdbc.JdbcCatalog\")\nspark.sql(\"CREATE OR REPLACE VIEW prod.db.v AS SELECT ...\")","handlingStrategy":"type-guard","validationCode":"if (!(catalog instanceof ViewCatalog)) {\n  LOG.error(\"Catalog {} cannot replace views; reconfigure catalog-impl\", catalogName);\n  return;\n}","typeGuard":"static boolean replaceViewSupported(Object catalog) {\n  return catalog instanceof ViewCatalog;\n}","tryCatchPattern":"try {\n  spark.sql(\"CREATE OR REPLACE VIEW \" + ident + \" AS \" + sql);\n} catch (UnsupportedOperationException e) {\n  if (e.getMessage().startsWith(\"Replacing a view is not supported\")) {\n    throw new ConfigurationException(\"Use a ViewCatalog-backed catalog or manage view SQL externally\");\n  }\n  throw e;\n}","preventionTips":["Assert ViewCatalog support at job startup before running replace DDL","Choose RESTCatalog/HiveCatalog/JdbcCatalog/Nessie for view workloads","Keep view definitions version-controlled externally if the catalog cannot host them","Re-run capability checks after catalog implementation upgrades"],"tags":["spark","view","unsupported-operation","catalog-capability"],"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"}