apache/iceberg · error · UnsupportedOperationException

Replacing a view is not supported by catalog: ${catalogName}

Error message

Replacing a view is not supported by catalog: ${catalogName}

What it means

Thrown by SparkSessionCatalog.replaceView when no underlying catalog supports view replacement: no Iceberg ViewCatalog is present and the session catalog is not a view catalog. ALTER VIEW ... AS SELECT / REPLACE VIEW cannot be served.

Source

Thrown at spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/SparkSessionCatalog.java:502

      String[] columnAliases,
      String[] columnComments,
      Map<String, String> properties)
      throws NoSuchNamespaceException, NoSuchViewException {
    if (asViewCatalog instanceof SupportsReplaceView) {
      return ((SupportsReplaceView) asViewCatalog)
          .replaceView(
              ident,
              sql,
              currentCatalog,
              currentNamespace,
              schema,
              queryColumnNames,
              columnAliases,
              columnComments,
              properties);
    }

    throw new UnsupportedOperationException(
        "Replacing a view is not supported by catalog: " + catalogName);
  }

  @Override
  public View alterView(Identifier ident, ViewChange... changes)
      throws NoSuchViewException, IllegalArgumentException {
    if (null != asViewCatalog && asViewCatalog.viewExists(ident)) {
      return asViewCatalog.alterView(ident, changes);
    } else if (isViewCatalog()) {
      return getSessionCatalog().alterView(ident, changes);
    }

    throw new UnsupportedOperationException(
        "Altering a view is not supported by catalog: " + catalogName);
  }

  @Override
  public boolean dropView(Identifier ident) {

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Route the replace to a catalog with view support (drop and qualify with the Iceberg view-capable catalog name).
  2. Manually DROP VIEW then CREATE VIEW if replacement is not supported by the target.
  3. Configure an Iceberg ViewCatalog as the session catalog delegate.

Example fix

// before
CREATE OR REPLACE VIEW spark_catalog.db.v AS SELECT ...
// after
DROP VIEW IF EXISTS spark_catalog.db.v;
CREATE VIEW spark_catalog.db.v AS SELECT ...
Defensive patterns

Strategy: type-guard

Validate before calling

if (!(catalog instanceof ViewCatalog)) { throw new IllegalStateException("replace view needs a ViewCatalog"); }

Type guard

boolean supportsReplaceView(Catalog catalog) { return catalog instanceof ViewCatalog; }

Try / catch

try { catalog.replaceView(ident, ...); } catch (UnsupportedOperationException e) { /* drop+recreate fallback */ }

Prevention

When it happens

Trigger: Executing CREATE OR REPLACE VIEW (or REPLACE VIEW) against a session catalog whose delegate lacks ViewCatalog support.

Common situations: Migrating SQL workloads that assume replaceable views to a catalog without view support; unqualified view DDL landing on the default session catalog instead of the Iceberg catalog.

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/84f687d2a7740744. Report an issue: GitHub.