{"record":{"id":"0814922a142e8c6e","repo":"apache/iceberg","slug":"creating-a-view-is-not-supported-by-catalog-catal","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/SparkCatalog.java","lineNumber":645,"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                .create();\n        return new SparkView(catalogName, view);\n      } catch (org.apache.iceberg.exceptions.NoSuchNamespaceException e) {\n        throw new NoSuchNamespaceException(currentNamespace);\n      } catch (AlreadyExistsException e) {\n        throw new ViewAlreadyExistsException(ident);\n      }\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 (null != asViewCatalog) {\n      Schema icebergSchema = SparkSchemaUtil.convert(schema);\n","sourceCodeStart":627,"sourceCodeEnd":663,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java#L627-L663","documentation":"SparkCatalog.createView throws UnsupportedOperationException when the wrapped catalog does not implement the Iceberg ViewCatalog interface (asViewCatalog is null). Views are only supported by view-capable catalogs (Hive, JDBC, REST, Nessie, in-memory), so createView cannot proceed and reports the unsupported catalog name.","triggerScenarios":"Executing CREATE VIEW (routed to createView at SparkCatalog.java:606) against spark.sql.catalog.<name> set to a table-only Iceberg catalog such as HadoopCatalog (spark.sql.catalog.<name>=org.apache.iceberg.hadoop.HadoopCatalog) or any custom Catalog implementation lacking ViewCatalog.","commonSituations":"Teams upgrading to Spark 3.4+ SQL view syntax while still on the Hadoop catalog; examples/tests that configure a HadoopCatalog then run view DDL; custom catalog implementations that never added ViewCatalog support.","solutions":["Switch spark.sql.catalog.<name> to a view-capable catalog implementation (HiveCatalog, JdbcCatalog, RESTCatalog, NessieCatalog, or SQL extensions' in-memory catalog).","If views must live in Hadoop-style storage, use a catalog that implements ViewCatalog with a compatible backend.","Avoid view DDL against this catalog; materialize results as an Iceberg table instead (CREATE TABLE AS SELECT).","For custom catalogs, implement org.apache.iceberg.catalog.ViewCatalog to enable view operations."],"exampleFix":"// before\nspark.conf.set(\"spark.sql.catalog.local\", \"org.apache.iceberg.hadoop.HadoopCatalog\");\nspark.sql(\"CREATE VIEW local.ns.v AS SELECT 1\"); // UnsupportedOperationException\n\n// after\nspark.conf.set(\"spark.sql.catalog.local\", \"org.apache.iceberg.jdbc.JdbcCatalog\");\nspark.sql(\"CREATE VIEW local.ns.v AS SELECT 1\");","handlingStrategy":"validation","validationCode":"Catalog catalog = Spark3Util.loadIcebergCatalog(spark, catalogName);\nif (!(catalog instanceof ViewCatalog)) {\n  throw new IllegalStateException(\"Catalog \" + catalogName + \" does not support views\");\n}","typeGuard":"boolean supportsViews(Catalog catalog) {\n  return catalog instanceof org.apache.iceberg.catalog.ViewCatalog;\n}","tryCatchPattern":"try {\n  spark.sql(\"CREATE VIEW \" + ident + \" AS \" + sqlText);\n} catch (UnsupportedOperationException e) {\n  if (e.getMessage().contains(\"Creating a view is not supported\")) {\n    // fall back to CREATE TABLE AS SELECT or switch catalogs\n  }\n}","preventionTips":["Check spark.sql.catalog.<name> implementation class supports ViewCatalog before running view DDL.","Prefer HiveCatalog/JdbcCatalog/RESTCatalog/NessieCatalog for workloads with views.","Add a session-startup assertion that required catalogs implement ViewCatalog.","Keep catalog configuration in version-controlled configs so class changes are reviewed."],"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-23T08:17:48.524Z"}