apache/iceberg · error · RuntimeException

e (wrapped NoSuchNamespaceException)

Error message

e (wrapped NoSuchNamespaceException)

What it means

In SparkSessionCatalog.listViews, a NoSuchNamespaceException from the underlying view catalog is caught and rethrown wrapped in a plain RuntimeException. It means the namespace passed to listViews does not exist in any configured view catalog.

Source

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

  @Override
  public UnboundFunction loadFunction(Identifier ident) throws NoSuchFunctionException {
    try {
      return super.loadFunction(ident);
    } catch (NoSuchFunctionException e) {
      return getSessionCatalog().loadFunction(ident);
    }
  }

  @Override
  public Identifier[] listViews(String... namespace) {
    try {
      if (null != asViewCatalog) {
        return asViewCatalog.listViews(namespace);
      } else if (isViewCatalog()) {
        return getSessionCatalog().listViews(namespace);
      }
    } catch (NoSuchNamespaceException e) {
      throw new RuntimeException(e);
    }

    return new Identifier[0];
  }

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

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

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Verify the namespace exists: SHOW NAMESPACES IN <catalog> before listing views.
  2. Create the namespace first (CREATE NAMESPACE) if it is missing.
  3. Catch NoSuchNamespaceException upstream instead of relying on the wrapped RuntimeException, or check isViewCatalog support.

Example fix

// before
SHOW VIEWS IN prod.wrongdb
// after
CREATE NAMESPACE IF NOT EXISTS prod.db;
SHOW VIEWS IN prod.db
Defensive patterns

Strategy: validation

Validate before calling

Namespace ns = Namespace.of("prod", "db");
if (!catalog.namespaceExists(ns)) { throw new IllegalArgumentException("namespace missing: " + ns); }

Try / catch

try { catalog.listViews(ns); } catch (RuntimeException e) { if (e.getCause() instanceof NoSuchNamespaceException) { /* create namespace or fix name */ } else throw e; }

Prevention

When it happens

Trigger: Calling SHOW VIEWS (or listViews directly) on a namespace that does not exist in the delegate or Iceberg view catalog.

Common situations: Typo in namespace/database name; querying views in a database that was dropped; Spark resolving an unqualified namespace against the session catalog that lacks it.

Related errors


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