{"record":{"id":"c561d55deb450c53","repo":"apache/iceberg","slug":"missingcatalogabilityerror-plugin-views","errorCode":null,"errorMessage":"missingCatalogAbilityError(plugin, \"views\")","messagePattern":"missingCatalogAbilityError\\(plugin, \"views\"\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"spark/v3.5/spark-extensions/src/main/scala/org/apache/spark/sql/catalyst/analysis/ViewUtil.scala","lineNumber":47,"sourceCode":"    case viewCatalog: ViewCatalog =>\n      try {\n        Option(viewCatalog.loadView(ident))\n      } catch {\n        case _: NoSuchViewException => None\n      }\n    case _ => None\n  }\n\n  def isViewCatalog(catalog: CatalogPlugin): Boolean = {\n    catalog.isInstanceOf[ViewCatalog]\n  }\n\n  implicit class IcebergViewHelper(plugin: CatalogPlugin) {\n    def asViewCatalog: ViewCatalog = plugin match {\n      case viewCatalog: ViewCatalog =>\n        viewCatalog\n      case _ =>\n        throw QueryCompilationErrors.missingCatalogAbilityError(plugin, \"views\")\n    }\n  }\n}\n","sourceCodeStart":29,"sourceCodeEnd":51,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v3.5/spark-extensions/src/main/scala/org/apache/spark/sql/catalyst/analysis/ViewUtil.scala#L29-L51","documentation":"Spark analysis error raised when a catalog plugin is used in a view operation (CREATE/REPLACE VIEW etc. handled by Iceberg's extensions) but the catalog does not implement ViewCatalog. ViewUtil's IcebergViewHelper.asViewCatalog inspects the resolved CatalogPlugin and throws QueryCompilationErrors.missingCatalogAbilityError(plugin, \"views\") when the cast to ViewCatalog is impossible. It means the chosen catalog cannot store views, so the view command cannot proceed.","triggerScenarios":"Executing CREATE VIEW / REPLACE VIEW / DROP VIEW (via Iceberg spark-extensions resolution) against a catalog that only implements TableCatalog — e.g. spark_catalog (the session catalog), a REST/Hive catalog version lacking view support, or the default file catalog — instead of a ViewCatalog implementation.","commonSituations":"Running CREATE VIEW ... USING iceberg or plain view DDL where the current catalog is HadoopCatalog/session catalog; mixing catalogs where views were created under an Iceberg REST catalog but a migration points at HiveCatalog; Spark versions where the configured catalog build lacks ViewCatalog support.","solutions":["Set the command's catalog to one that implements ViewCatalog (e.g. an Iceberg REST catalog with view support) via USE <catalog> or a fully qualified catalog.database.view name.","Check the catalog implementation registered in spark.sql.catalog.<name> — switch it to an Iceberg catalog version that supports views.","If the session catalog (spark_catalog) is required for tables, keep view DDL on a separate ViewCatalog-capable catalog.","Upgrade the Iceberg runtime/catalog implementation if it predates view support."],"exampleFix":"// before (catalog does not support views)\nCREATE VIEW prod.events_view AS SELECT * FROM prod.events;\n// after\nUSE prod_catalog; -- ViewCatalog-backed REST catalog\nCREATE VIEW prod.events_view AS SELECT * FROM prod.events;","handlingStrategy":"validation","validationCode":"CatalogPlugin catalog = ...; // resolved catalog for the view command\nif (!(catalog instanceof ViewCatalog)) {\n  throw new IllegalArgumentException(\"Catalog \" + catalog.name() + \" does not support views; use a ViewCatalog-backed catalog\");\n}","typeGuard":"def supportsViews(catalog: CatalogPlugin): Boolean = catalog match {\n  case _: ViewCatalog => true\n  case _ => false\n}","tryCatchPattern":"try {\n  spark.sql(\"CREATE VIEW prod_catalog.db.v AS SELECT ...\")\n} catch {\n  case e: AnalysisException if e.getMessage.contains(\"doesn't support views\") ||\n      e.getMessage.contains(\"view\") =>\n    // switch to a ViewCatalog-capable catalog and retry\n}","preventionTips":["Route view DDL to catalogs implementing ViewCatalog (Iceberg REST catalog with view support)","Keep spark_catalog/HadoopCatalog for tables only, not Iceberg views","USE <catalog> explicitly before view commands","Confirm view support in the catalog implementation version before migration"],"tags":["spark","views","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-14T11:17:12.474Z"}