apache/iceberg · error · NoSuchViewException

NoSuchViewException(ident)

Error message

NoSuchViewException(ident)

What it means

loadView wraps the underlying ViewCatalog result: if loadView on the Iceberg view fails with NoSuchViewException it is rethrown as Spark's NoSuchViewException for the identifier. This final throw is the fallback when the wrapped catalog implements ViewCatalog (asViewCatalog != null) but the view was not found — Spark's analyzer uses it to decide a name is unresolvable.

Source

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

          .toArray(Identifier[]::new);
    }

    return new Identifier[0];
  }

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

  @Override
  public View loadView(Identifier ident) throws NoSuchViewException {
    if (null != asViewCatalog) {
      try {
        org.apache.iceberg.view.View view = asViewCatalog.loadView(buildIdentifier(ident));
        return new SparkView(catalogName, view);
      } catch (org.apache.iceberg.exceptions.NoSuchViewException e) {
        throw new NoSuchViewException(ident);
      }
    }

    throw new NoSuchViewException(ident);
  }

  @Override
  public View createView(ViewInfo viewInfo)
      throws ViewAlreadyExistsException, NoSuchNamespaceException {
    if (null != asViewCatalog && viewInfo != null) {
      Identifier ident = viewInfo.ident();
      String sql = viewInfo.sql();
      String currentCatalog = viewInfo.currentCatalog();
      String[] currentNamespace = viewInfo.currentNamespace();
      StructType schema = viewInfo.schema();
      String[] queryColumnNames = viewInfo.queryColumnNames();
      Map<String, String> properties = viewInfo.properties();
      Schema icebergSchema = SparkSchemaUtil.convert(schema);

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Confirm the view exists: SHOW VIEWS IN catalog.db, and check the fully qualified identifier (catalog.database.name)
  2. Check you are loading a view, not a table with the same name — Iceberg keeps them in separate namespaces in the catalog
  3. Refresh/replace the Spark session or clear catalog caches if the view was created recently by another job
  4. Create the missing view (CREATE VIEW) if it should exist

Example fix

// before
SELECT * FROM prod.reporting.daily_revenue; // NoSuchViewException
// after
SHOW VIEWS IN prod.reporting; // find correct name
SELECT * FROM prod.reporting.daily_revenue_v2;
Defensive patterns

Strategy: try-catch

Validate before calling

boolean viewExists = spark.sql("SHOW VIEWS IN " + db).collectAsList().stream()
    .anyMatch(r -> r.getString(0).equalsIgnoreCase(viewName));
if (!viewExists) { /* create view or correct the reference */ }

Try / catch

try {
  View v = sparkCatalog.loadView(Identifier.of(new String[]{db}, viewName));
} catch (org.apache.spark.sql.catalyst.analysis.NoSuchViewException e) {
  // create the view or fall back to a table reference
}

Prevention

When it happens

Trigger: SELECT/DESCRIBE VIEW on catalog.db.view where asViewCatalog.loadView(buildIdentifier(ident)) throws org.apache.iceberg.exceptions.NoSuchViewException because no such view exists in the catalog; also the fall-through throw when asViewCatalog is null and loadView is invoked anyway.

Common situations: Referencing a view with the wrong name, wrong database, or wrong catalog prefix; querying a TABLE as a view (or vice versa) — Iceberg distinguishes tables and views; stale Spark session cache after the view was renamed/dropped; environment mismatch (view created in dev, query in prod).

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