apache/iceberg · error

missingCatalogViewsAbilityError(plugin)

Error message

missingCatalogViewsAbilityError(plugin)

What it means

In the Spark 4.2 main source tree, ViewUtil's IcebergViewHelper.asViewCatalog throws missingCatalogViewsAbilityError when the CatalogPlugin does not implement ViewCatalog. It is the type-narrowing guard for all view operations routed through Iceberg's extended analysis: view commands must land on a view-capable catalog.

Solutions

  1. Use a ViewCatalog implementation for view operations (REST, Hive, or another view-capable catalog)
  2. Qualify the view name with the correct catalog so resolution does not fall back to a non-view catalog
  3. Upgrade the catalog implementation to a version supporting views
  4. Move view definitions to the session catalog if the target cannot hold views

Example fix

-- before
CREATE VIEW table_only_catalog.db.v AS SELECT 1;
-- after
CREATE VIEW rest_catalog.db.v AS SELECT 1; -- RESTCatalog implements ViewCatalog
Defensive patterns

Strategy: validation

Validate before calling

def supportsViews(c: CatalogPlugin): Boolean = c.isInstanceOf[ViewCatalog]
assert(supportsViews(catalogManager.currentCatalog), "current catalog cannot store views")

Type guard

def viewCatalogOrNull(plugin: CatalogPlugin): ViewCatalog =
  if (plugin.isInstanceOf[ViewCatalog]) plugin.asInstanceOf[ViewCatalog] else null

Prevention

When it happens

Trigger: Any view command (CREATE/ALTER/DROP/SHOW VIEW) resolved to a catalog that implements CatalogPlugin but not ViewCatalog, so the implicit asViewCatalog conversion fails.

Common situations: Default session catalog without view support receiving view DDL; catalog registered only for tables; catalog implementation version lacking view support while Spark expects it.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/4ba9f08a0874b2ec. Report an issue: GitHub.

Appendix: source

Thrown at spark/v4.2/spark/src/main/scala/org/apache/spark/sql/catalyst/analysis/ViewUtil.scala:90

      case _ =>
        None
    }

  def isIcebergViewCatalog(catalog: CatalogPlugin): Boolean = {
    catalog.isInstanceOf[ViewCatalog] && catalog.isInstanceOf[HasIcebergCatalog]
  }

  private def isIcebergView(view: View): Boolean = {
    !view.isInstanceOf[V1View] &&
    "iceberg".equalsIgnoreCase(view.properties.get(TableCatalog.PROP_PROVIDER))
  }

  implicit class IcebergViewHelper(plugin: CatalogPlugin) {
    def asViewCatalog: ViewCatalog = plugin match {
      case viewCatalog: ViewCatalog =>
        viewCatalog
      case _ =>
        throw QueryCompilationErrors.missingCatalogViewsAbilityError(plugin)
    }
  }
}

View on GitHub (pinned to 86d9c8fc54)