apache/iceberg · error · NoSuchViewException

NoSuchViewException(fromIdentifier)

Error message

NoSuchViewException(fromIdentifier)

What it means

In renameView, if the ViewCatalog reports NoSuchViewException for the source identifier, SparkCatalog rethrows it as a Spark NoSuchViewException wrapping fromIdentifier. The rename fails because the view being renamed does not exist in the catalog.

Source

Thrown at spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java:754

  }

  @Override
  public boolean dropView(Identifier ident) {
    if (null != asViewCatalog) {
      return asViewCatalog.dropView(buildIdentifier(ident));
    }

    return false;
  }

  @Override
  public void renameView(Identifier fromIdentifier, Identifier toIdentifier)
      throws NoSuchViewException, ViewAlreadyExistsException {
    if (null != asViewCatalog) {
      try {
        asViewCatalog.renameView(buildIdentifier(fromIdentifier), buildIdentifier(toIdentifier));
      } catch (org.apache.iceberg.exceptions.NoSuchViewException e) {
        throw new NoSuchViewException(fromIdentifier);
      } catch (org.apache.iceberg.exceptions.AlreadyExistsException e) {
        throw new ViewAlreadyExistsException(toIdentifier);
      }
    } else {
      throw new UnsupportedOperationException(
          "Renaming a view is not supported by catalog: " + catalogName);
    }
  }

  @Override
  public final void initialize(String name, CaseInsensitiveStringMap options) {
    super.initialize(name, options);

    this.cacheEnabled =
        PropertyUtil.propertyAsBoolean(
            options, CatalogProperties.CACHE_ENABLED, CatalogProperties.CACHE_ENABLED_DEFAULT);

    boolean cacheCaseSensitive =

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Confirm the source view exists with SHOW VIEWS in the relevant namespace.
  2. Fix the from-identifier namespace/name passed to the rename.
  3. Verify the session is pointed at the catalog where the view was created.

Example fix

// before
spark.sql("ALTER VIEW analytic.v RENAME TO analytic.v2")
// after
spark.sql("ALTER VIEW analytics.v RENAME TO analytics.v2")
Defensive patterns

Strategy: try-catch

Validate before calling

if (!sparkCatalog.viewExists(fromIdent)) {
  throw new IllegalStateException("Source view missing: " + fromIdent);
}

Try / catch

try {
  sparkCatalog.renameView(from, to);
} catch (NoSuchViewException e) {
  LOG.error("Cannot rename: source view {} does not exist", from, e);
}

Prevention

When it happens

Trigger: ALTER VIEW RENAME TO where the source view name is missing or misspelled in a ViewCatalog-capable catalog; wrong namespace on the from-identifier.

Common situations: Rename scripts run against a different catalog/namespace than intended; typos in view names; case-sensitivity mismatches.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


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