{"record":{"id":"2acc93da842a46bd","repo":"apache/iceberg","slug":"creating-or-replacing-a-view-is-not-supported-by-c","errorCode":null,"errorMessage":"Creating or replacing a view is not supported by catalog: ${catalogName}","messagePattern":"Creating or replacing a view is not supported by catalog: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/SparkSessionCatalog.java","lineNumber":626,"sourceCode":"    throw new NoSuchViewException(ident);\n  }\n\n  @Override\n  public View createOrReplaceView(Identifier ident, View view)\n      throws ViewAlreadyExistsException, NoSuchNamespaceException {\n    checkTableNotExists(ident);\n\n    if (null != asViewCatalog && asViewCatalog.viewExists(ident)) {\n      return asViewCatalog.createOrReplaceView(ident, view);\n    } else if (isViewCatalog() && getSessionCatalog().viewExists(ident)) {\n      return getSessionCatalog().createOrReplaceView(ident, view);\n    } else if (null != asViewCatalog) {\n      return asViewCatalog.createOrReplaceView(ident, view);\n    } else if (isViewCatalog()) {\n      return getSessionCatalog().createOrReplaceView(ident, view);\n    }\n\n    throw new UnsupportedOperationException(\n        \"Creating or replacing a view is not supported by catalog: \" + catalogName);\n  }\n\n  @Override\n  public boolean dropView(Identifier ident) {\n    if (null != asViewCatalog && asViewCatalog.viewExists(ident)) {\n      return asViewCatalog.dropView(ident);\n    } else if (isViewCatalog()) {\n      return getSessionCatalog().dropView(ident);\n    }\n\n    return false;\n  }\n\n  @Override\n  public void renameView(Identifier fromIdentifier, Identifier toIdentifier)\n      throws NoSuchViewException, ViewAlreadyExistsException {\n    checkTableNotExists(toIdentifier);","sourceCodeStart":608,"sourceCodeEnd":644,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/SparkSessionCatalog.java#L608-L644","documentation":"SparkSessionCatalog delegates view DDL to the session catalog when it implements ViewCatalog. If neither the asViewCatalog view catalog nor the session catalog supports views, createOrReplaceView throws this UnsupportedOperationException. It signals the configured catalog cannot manage views at all.","triggerScenarios":"Calling catalog.createOrReplaceView(ident, view) on a SparkCatalog/SparkSessionCatalog whose session catalog does not implement ViewCatalog and no separate view catalog was injected.","commonSituations":"Using a catalog (e.g. HadoopCatalog or a plain table-only catalog) that never supported views; forgetting to configure a view-capable catalog like JDBC/Hive; Spark version/catalog misconfiguration where view support isn't wired.","solutions":["Configure the catalog so it implements ViewCatalog (e.g. use a Hive or JDBC catalog with view support)","Pass a dedicated view catalog via asViewCatalog / catalog configuration so view DDL is delegated","Create the view through Spark SQL against a view-capable catalog instead of the Iceberg API","Use createView or table-only workflows if view management is genuinely not needed"],"exampleFix":"// before\nspark.sql(\"CREATE OR REPLACE VIEW unsupported_cat.db.v AS SELECT 1\") // throws\n// after\nspark.conf.set(\"spark.sql.catalog.mycat\", \"org.apache.iceberg.spark.SparkCatalog\")\nspark.conf.set(\"spark.sql.catalog.mycat.catalog-impl\", \"org.apache.iceberg.jdbc.JdbcCatalog\") // view-capable session catalog","handlingStrategy":"type-guard","validationCode":"boolean supportsViews = catalog instanceof org.apache.iceberg.view.ViewCatalog;","typeGuard":"if (!(catalog instanceof org.apache.iceberg.view.ViewCatalog)) {\n  throw new IllegalStateException(\"Catalog does not support views: \" + catalog.name());\n}","tryCatchPattern":"try {\n  catalog.createOrReplaceView(ident, view);\n} catch (UnsupportedOperationException e) {\n  // route view DDL to a view-capable catalog or fail fast with a clear message\n}","preventionTips":["Choose catalog implementations with ViewCatalog support when views are required","Smoke-test view DDL (CREATE VIEW) during catalog onboarding","Keep view and table catalogs clearly separated in Spark conf","Document which catalogs in your stack support views"],"tags":["spark","catalog","views","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-14T16:17:12.679Z"}