apache/iceberg · error · NoSuchNamespaceException

Cannot list views for namespace. Namespace does not exist: %

Error message

Cannot list views for namespace. Namespace does not exist: %s

What it means

NoSuchNamespaceException from InMemoryCatalog.listViews: the requested namespace does not exist (and is not the empty root namespace, which is allowed), so views cannot be listed. The %s is the missing Namespace; callers should check namespaceExists first if the listing is optional.

Source

Thrown at core/src/main/java/org/apache/iceberg/inmemory/InMemoryCatalog.java:347

        .distinct()
        .sorted(Comparator.comparing(n -> DOT.join(n.levels())))
        .collect(Collectors.toList());
  }

  @Override
  public void close() throws IOException {
    if (closeableGroup != null) {
      closeableGroup.close();
    }
    namespaces.clear();
    tables.clear();
    views.clear();
  }

  @Override
  public List<TableIdentifier> listViews(Namespace namespace) {
    if (!namespaceExists(namespace) && !namespace.isEmpty()) {
      throw new NoSuchNamespaceException(
          "Cannot list views for namespace. Namespace does not exist: %s", namespace);
    }

    return views.keySet().stream()
        .filter(v -> v.namespace().equals(namespace))
        .sorted(Comparator.comparing(TableIdentifier::toString))
        .collect(Collectors.toList());
  }

  @Override
  protected ViewOperations newViewOps(TableIdentifier identifier) {
    return new InMemoryViewOperations(io, identifier);
  }

  @Override
  public boolean dropView(TableIdentifier identifier) {
    synchronized (this) {
      return null != views.remove(identifier);

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Check namespaceExists(ns) before listing views
  2. Fix the namespace name (exact levels, case-sensitive)
  3. Create the namespace first if it should exist

Example fix

// before
List<TableIdentifier> views = catalog.listViews(ns);
// after
List<TableIdentifier> views = catalog.namespaceExists(ns)
    ? catalog.listViews(ns)
    : Collections.emptyList();
Defensive patterns

Strategy: validation

Validate before calling

if (!catalog.namespaceExists(ns)) throw new IllegalStateException("Missing namespace: " + ns);

Try / catch

try { return catalog.listViews(ns); } catch (NoSuchNamespaceException e) { return List.of(); }

Prevention

When it happens

Trigger: Calling catalog.listViews(ns) for a nonexistent namespace; unlike listTables-like checks, the empty namespace is allowed, so this fires only for non-empty unknown namespaces.

Common situations: Enumerating views under a dropped namespace; typos in namespace levels; UI listings built from cached namespace names.

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