{"record":{"id":"3b915467b89a2acf","repo":"apache/iceberg","slug":"creating-a-view-is-not-supported-by-catalog-catal-3b9154","errorCode":null,"errorMessage":"Creating a view is not supported by catalog: catalogName","messagePattern":"Creating a view is not supported by catalog: catalogName","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/SparkSessionCatalog.java","lineNumber":495,"sourceCode":"          queryColumnNames,\n          columnAliases,\n          columnComments,\n          properties);\n    } else if (isViewCatalog()) {\n      return getSessionCatalog()\n          .createView(\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        \"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":477,"sourceCodeEnd":513,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/SparkSessionCatalog.java#L477-L513","documentation":"Thrown by SparkSessionCatalog.createView when neither the Iceberg view catalog nor the session catalog supports view creation (asViewCatalog is null and the session catalog cannot create views). View creation is a catalog capability; catalogs without ViewCatalog support reject CREATE VIEW explicitly with UnsupportedOperationException.","triggerScenarios":"Running CREATE VIEW against a SparkSessionCatalog configured with a delegate that is not a view catalog and with asViewCatalog == null; also reached when session-catalog delegation path cannot handle view creation for the given options.","commonSituations":"Iceberg versions or catalog impls (HadoopCatalog, JDBC before view support) lacking ViewCatalog; CREATE VIEW routed to the session catalog on a setup where views aren't supported; mixing environments where dev supports views but prod catalog does not.","solutions":["Configure a catalog implementation that implements ViewCatalog (HiveCatalog, REST catalog with views, JDBC with view support).","Create the view in a catalog that supports it rather than the session catalog.","Upgrade the Iceberg runtime if the target catalog added view support in a newer version.","As a fallback, use Spark's temporary/global temp views (not persisted) for non-catalog view needs."],"exampleFix":"// before\nspark.conf.set(\"spark.sql.catalog.local\", \"org.apache.iceberg.hadoop.HadoopCatalog\");\nspark.sql(\"CREATE VIEW local.db.v AS SELECT ...\"); // fails\n// after\nspark.conf.set(\"spark.sql.catalog.local\", \"org.apache.iceberg.hive.HiveCatalog\"); // ViewCatalog\nspark.sql(\"CREATE VIEW local.db.v AS SELECT ...\");","handlingStrategy":"validation","validationCode":"if (!(catalog instanceof ViewCatalog) && !sessionSupportsViewCreate()) { throw new IllegalStateException(\"view creation unsupported by this catalog\"); }","typeGuard":"boolean canCreateViews = (catalog instanceof ViewCatalog);","tryCatchPattern":"try { catalog.createView(ident, sql, ...); } catch (UnsupportedOperationException e) { /* create temp view or switch catalogs */ }","preventionTips":["Provision view-capable catalogs for environments that run CREATE VIEW","Feature-detect ViewCatalog before issuing DDL","Align catalog implementations across dev/prod"],"tags":["spark","view","unsupported-operation","catalog"],"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"}