{"record":{"id":"342c571e240065c5","repo":"apache/iceberg","slug":"creating-a-view-is-not-supported-by-catalog","errorCode":null,"errorMessage":"Creating a view is not supported by catalog: ","messagePattern":"Creating 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":513,"sourceCode":"    }\n\n    throw new NoSuchViewException(ident);\n  }\n\n  @Override\n  public View createView(ViewInfo viewInfo)\n      throws ViewAlreadyExistsException, NoSuchNamespaceException {\n    if (viewInfo == null) {\n      return null;\n    }\n\n    if (null != asViewCatalog) {\n      return asViewCatalog.createView(viewInfo);\n    } else if (isViewCatalog()) {\n      return getSessionCatalog().createView(viewInfo);\n    }\n\n    throw new UnsupportedOperationException(\n        \"Creating a view is not supported by catalog: \" + catalogName);\n  }\n\n  @Override\n  public View replaceView(\n      Identifier ident,\n      String sql,\n      String currentCatalog,\n      String[] currentNamespace,\n      StructType schema,\n      String[] queryColumnNames,\n      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(","sourceCodeStart":495,"sourceCodeEnd":531,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/SparkSessionCatalog.java#L495-L531","documentation":"createView in SparkSessionCatalog throws UnsupportedOperationException when no view-capable catalog is available: the delegate is not a ViewCatalog and the session catalog is not view-capable. Iceberg only proxies view creation when the underlying catalog implements Spark's ViewCatalog interface.","triggerScenarios":"Executing CREATE VIEW against a catalog whose delegate lacks ViewCatalog support; SparkSessionCatalog initialized with a table-only delegate; isViewCatalog() is false and asViewCatalog is null.","commonSituations":"Trying to create views in spark_catalog backed by a non-view session catalog; older Spark versions or catalog plugins without view support; expecting Iceberg to add view support that the underlying catalog does not have.","solutions":["Configure a view-capable catalog (e.g. an Iceberg REST/Hive catalog registered with view support) and create the view there","Create the view through Spark's session catalog (V2SessionCatalog) rather than the Iceberg catalog","Upgrade the underlying catalog plugin to a version implementing ViewCatalog"],"exampleFix":"// before\nspark.sql(\"CREATE VIEW iceberg.db.v AS SELECT ...\"); // catalog lacks view support\n// after\nspark.sql(\"CREATE VIEW spark_catalog.db.v AS SELECT ...\"); // session catalog supports views","handlingStrategy":"fallback","validationCode":"// only create views where the catalog implements ViewCatalog\nif (catalog instanceof ViewCatalog) {\n  ((ViewCatalog) catalog).createView(viewInfo);\n}","typeGuard":"boolean supportsViews(Catalog c) { return c instanceof ViewCatalog; }","tryCatchPattern":"try {\n  catalog.createView(viewInfo);\n} catch (UnsupportedOperationException e) {\n  // create the view in the session catalog instead\n}","preventionTips":["Verify the target catalog advertises view support before emitting CREATE VIEW","Keep view DDL in a catalog known to support Iceberg views (REST/Hive with views enabled)"],"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"}