apache/iceberg · error · NoSuchViewException

View not found

Error message

View not found: ${ident}

What it means

Thrown by SparkCatalog.loadView when the view identified by ident does not exist in the underlying Iceberg view catalog, or when the catalog does not support views at all. It converts the Iceberg NoSuchViewException into a Spark NoSuchViewException. Any Spark query or command that resolves a view through this catalog will surface it.

Solutions

  1. Confirm the view exists via SHOW VIEWS IN <catalog.namespace>
  2. Verify the configured catalog implements ViewCatalog (e.g. REST/Hive/JDBC catalogs with view support, not a read-only or table-only catalog)
  3. Check the fully-qualified view identifier including the correct catalog and namespace
  4. Recreate the view if it was dropped

Example fix

// before
Dataset<Row> df = spark.read().table("prod.mart.my_view"); // View not found: prod.mart.my_view
// after
if (!spark.catalog().viewExists("prod.mart.my_view")) {
  spark.sql("CREATE VIEW prod.mart.my_view AS SELECT ...");
}
Dataset<Row> df = spark.read().table("prod.mart.my_view");
Defensive patterns

Strategy: validation

Validate before calling

Identifier ident = Identifier.of(new String[]{"db"}, "my_view");
if (!viewCatalog.viewExists(ident)) {
  throw new IllegalArgumentException("View missing: " + ident);
}

Type guard

boolean supportsViews(Catalog catalog) {
  return catalog instanceof SparkCatalog
      && ((SparkCatalog) catalog).viewExists(Identifier.of(namespace, name));
}

Try / catch

try {
  return catalog.loadView(ident);
} catch (NoSuchViewException e) {
  LOG.warn("View {} not found in {}", ident, catalogName);
  return Optional.empty();
}

Prevention

When it happens

Trigger: SELECT or DESCRIBE VIEW on a view that was never created or already dropped; calling catalog.loadView(ident) directly; the catalog lacks a ViewCatalog implementation (asViewCatalog == null) so every loadView fails.

Common situations: Using a catalog implementation that predates view support (formatVersion or catalog type without ViewCatalog); referencing views across catalogs (e.g. spark_catalog vs a REST catalog); renamed or dropped views with stale cached references.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java:603

          .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)