apache/iceberg · error · UnsupportedOperationException

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

Error message

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

What it means

Thrown by SparkSessionCatalog.alterView when neither the Iceberg view catalog nor the session catalog can serve view alteration: the view does not resolve to a view-capable catalog. View changes (e.g. ALTER VIEW ... AS) cannot be applied.

Source

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

              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) {
    if (null != asViewCatalog && asViewCatalog.viewExists(ident)) {
      return asViewCatalog.dropView(ident);
    } else if (isViewCatalog()) {
      return getSessionCatalog().dropView(ident);
    }

    return false;
  }

  @Override
  public void renameView(Identifier fromIdentifier, Identifier toIdentifier)
      throws NoSuchViewException, ViewAlreadyExistsException {
    if (null != asViewCatalog && asViewCatalog.viewExists(fromIdentifier)) {

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Verify the view exists and lives in a view-capable catalog before altering.
  2. Use DROP VIEW + CREATE VIEW to apply the change in catalogs without alter support.
  3. Register/configure an Iceberg ViewCatalog that can handle view changes.

Example fix

// before
ALTER VIEW spark_catalog.db.v AS SELECT ...  // not a view catalog
// 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.viewExists(ident)) { throw new IllegalStateException("view not found for alter: " + ident); }

Type guard

boolean canAlterView(Catalog catalog, Identifier ident) { return catalog instanceof ViewCatalog && ((ViewCatalog) catalog).viewExists(ident); }

Try / catch

try { catalog.alterView(ident, changes); } catch (UnsupportedOperationException e) { /* recreate view with new definition */ }

Prevention

When it happens

Trigger: Executing ALTER VIEW on an identifier that is not visible to any registered view catalog (asViewCatalog null or view not existing, and session catalog not a view catalog).

Common situations: Altering a view in a catalog without view support; view name typo causing the supported-catalog branch to be skipped and the UnsupportedOperationException to surface.

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/64fc4f60df075dca. Report an issue: GitHub.