{"record":{"id":"8086c98f5dc5ef18","repo":"apache/iceberg","slug":"creating-a-view-is-not-supported-by-catalog-cat","errorCode":null,"errorMessage":"Creating a view is not supported by catalog: ${catalogName}","messagePattern":"Creating a view is not supported by catalog: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java","lineNumber":644,"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":626,"sourceCodeEnd":662,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java#L626-L662","documentation":"createView ends by throwing UnsupportedOperationException(\"Creating a view is not supported by catalog: \" + catalogName) when the catalog wrapped by SparkCatalog does not implement ViewCatalog (asViewCatalog == null). The catalog simply has no view capability, so view creation cannot be performed.","triggerScenarios":"CREATE VIEW against a SparkCatalog whose underlying catalog lacks ViewCatalog support (asViewCatalog == null) — always thrown regardless of the identifier.","commonSituations":"Older Iceberg versions (pre-1.4 / Spark < 3.4 integrations) without view support; custom catalog implementations that only implement TableCatalog; metastores (e.g. old HadoopCatalog configs) that cannot store views; session misconfiguration routing DDL to a table-only catalog.","solutions":["Use a view-capable catalog: upgrade Iceberg to >= 1.4 and configure a catalog impl that implements ViewCatalog (REST, JDBC, Hive, Nessie, etc.)","Rewrite the workload to use tables or temp views (CREATE TEMP VIEW) if the catalog cannot be changed","Check spark.sql.catalog.<name>.catalog-impl configuration points at the intended catalog class","If views are genuinely unsupported in your storage backend, replace the view with a shared table"],"exampleFix":"// before\nspark.sql.catalog.glue=org.apache.iceberg.spark.SparkCatalog\nspark.sql.catalog.glue.catalog-impl=org.apache.iceberg.hadoop.HadoopCatalog // table-only\nCREATE VIEW glue.db.v AS SELECT ...; // UnsupportedOperationException\n// after\nspark.sql.catalog.glue.catalog-impl=org.apache.iceberg.rest.RESTCatalog // ViewCatalog-capable\nCREATE VIEW glue.db.v AS SELECT ...;","handlingStrategy":"type-guard","validationCode":"// verify the catalog supports views before issuing CREATE VIEW\nboolean viewCapable = spark.sessionState().catalogManager().catalog(catalogName)\n    instanceof org.apache.iceberg.view.ViewCatalog;\nif (!viewCapable) { /* use CREATE TEMP VIEW or change catalog */ }","typeGuard":"if (catalog instanceof org.apache.iceberg.view.ViewCatalog vc) {\n  vc.buildView(Identifier.of(ns, name)).withSchema(schema).create();\n} else {\n  throw new UnsupportedOperationException(catalogName + \" cannot store views\");\n}","tryCatchPattern":"try {\n  spark.sql(\"CREATE VIEW \" + ident + \" AS SELECT ...;\");\n} catch (UnsupportedOperationException e) {\n  // fall back to temp view or persistent table\n  df.createOrReplaceTempView(name);\n}","preventionTips":["Configure a ViewCatalog-capable impl (REST/JDBC/Hive/Nessie on Iceberg >= 1.4)","Smoke-test view DDL against each catalog at environment startup","Use CREATE TEMP VIEW when persistence is not required","Keep catalog-impl settings documented per Spark session"],"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"}