{"record":{"id":"2597634c214d645b","repo":"apache/iceberg","slug":"view-operations-are-not-supported-by-catalog-ca","errorCode":null,"errorMessage":"View operations are not supported by catalog: ${catalogName}","messagePattern":"View operations are not supported by catalog: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java","lineNumber":629,"sourceCode":"\n  private static RuntimeException unexpectedViewCommitException(\n      String operation, Identifier ident, String failure, Exception cause) {\n    return new IllegalStateException(\n        String.format(\n            \"Cannot %s view %s because the underlying catalog %s\", operation, ident, failure),\n        cause);\n  }\n\n  private View commitView(Identifier ident, View view, ViewCommit viewCommit)\n      throws ViewAlreadyExistsException, NoSuchNamespaceException, NoSuchViewException {\n    Preconditions.checkArgument(view != null, \"Invalid view metadata: null\");\n\n    if (null == asViewCatalog) {\n      if (viewCommit == ViewCommit.REPLACE && tableExists(ident)) {\n        throw new NoSuchViewException(ident);\n      }\n\n      throw new UnsupportedOperationException(\n          \"View operations are not supported by catalog: \" + catalogName);\n    }\n\n    String[] currentNamespace = view.currentNamespace();\n    Map<String, String> properties = view.properties();\n    Schema icebergSchema = SparkSchemaUtil.convert(view.schema());\n    Map<String, String> props = ViewUtil.createProperties(view);\n    TableIdentifier viewIdentifier = buildIdentifier(ident);\n\n    try {\n      ViewBuilder builder =\n          asViewCatalog\n              .buildView(viewIdentifier)\n              .withDefaultCatalog(view.currentCatalog())\n              .withDefaultNamespace(Namespace.of(currentNamespace))\n              .withQuery(\"spark\", view.queryText())\n              .withSchema(icebergSchema)\n              .withLocation(properties.get(TableCatalog.PROP_LOCATION))","sourceCodeStart":611,"sourceCodeEnd":647,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java#L611-L647","documentation":"Guard in SparkCatalog.commitView: the operation was a view commit (create/replace), but the wrapped catalog does not implement ViewCatalog (asViewCatalog is null). Since view mutations need view-catalog support, the commit is refused rather than silently dropping the view change.","triggerScenarios":"CREATE VIEW / REPLACE VIEW / CREATE OR REPLACE VIEW executed against a catalog where asViewCatalog is null.","commonSituations":"Using HadoopCatalog or custom catalogs without view support; forgetting to configure a view-capable catalog (Hive/REST/N JDBC) in Spark session config.","solutions":["Configure a catalog that supports views, e.g. spark.sql.catalog.my_cat=org.apache.iceberg.spark.SparkCatalog with a Hive/REST/JDBC backend","Upgrade to an Iceberg catalog implementation with ViewCatalog support","Store views in Spark's built-in session catalog instead"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (!(sparkCatalog instanceof ViewCatalog)) {\n  throw new IllegalStateException(\"Configure a view-capable Iceberg catalog\");\n}","typeGuard":"boolean canCreateViews = catalog instanceof ViewCatalog;","tryCatchPattern":"try { spark.sql(\"CREATE VIEW cat.db.v AS SELECT ...\"); }\ncatch (UnsupportedOperationException e) { /* reconfigure catalog or use session catalog */ }","preventionTips":["Verify catalog capabilities during setup smoke tests","Use Hive/REST/JDBC catalogs when views are required","Document per-catalog feature support for the team"],"tags":["spark","view","unsupported-operation"],"backgroundTag":"operation-not-supported","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"}