apache/iceberg · error · NoSuchNamespaceException
Cannot list tables for namespace. Namespace does not exist:
Error message
Cannot list tables for namespace. Namespace does not exist: %s
What it means
InMemoryCatalog.listTables throws NoSuchNamespaceException when the requested namespace does not exist and is not empty (root). The in-memory catalog keeps namespaces explicitly; listing tables requires a valid namespace.
Source
Thrown at core/src/main/java/org/apache/iceberg/inmemory/InMemoryCatalog.java:154
}
synchronized (this) {
if (null == tables.remove(tableIdentifier)) {
return false;
}
}
if (purge && lastMetadata != null) {
CatalogUtil.dropTableData(ops.io(), lastMetadata);
}
return true;
}
@Override
public List<TableIdentifier> listTables(Namespace namespace) {
if (!namespaceExists(namespace) && !namespace.isEmpty()) {
throw new NoSuchNamespaceException(
"Cannot list tables for namespace. Namespace does not exist: %s", namespace);
}
return tables.keySet().stream()
.filter(t -> t.namespace().equals(namespace))
.sorted(Comparator.comparing(TableIdentifier::toString))
.collect(Collectors.toList());
}
@Override
public void renameTable(TableIdentifier from, TableIdentifier to) {
if (from.equals(to)) {
return;
}
synchronized (this) {
if (!namespaceExists(to.namespace())) {
throw new NoSuchNamespaceException(View on GitHub (pinned to 86d9c8fc54)
Solutions
- Call namespaceExists(namespace) first and create it if missing
- Correct the namespace identifier spelling/casing
- List namespaces with listNamespaces() to see what exists
- Catch NoSuchNamespaceException and return an empty list if acceptable
Example fix
// before
List<TableIdentifier> tables = catalog.listTables(Namespace.of("reporting"));
// after
Namespace ns = Namespace.of("reporting");
if (catalog.namespaceExists(ns)) {
List<TableIdentifier> tables = catalog.listTables(ns);
} Defensive patterns
Strategy: validation
Validate before calling
Namespace ns = Namespace.of("reporting");
if (!catalog.namespaceExists(ns)) { catalog.createNamespace(ns); } Try / catch
try { return catalog.listTables(ns); } catch (NoSuchNamespaceException e) { return List.of(); } Prevention
- Create namespaces explicitly in setup before use
- Compare namespace spellings with listNamespaces() output
- Keep namespace definitions in one shared constant/helper
- Account for case sensitivity in namespace names
When it happens
Trigger: Calling catalog.listTables(Namespace.of("a")) where namespace "a" was never created (or was dropped). Passing a multi-level namespace whose parent exists but leaf does not.
Common situations: Hardcoded namespace names that drift from what was created in tests; namespaces dropped by prior cleanup; case-sensitivity mismatches in namespace strings.
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
- Cannot rename %s to %s. Namespace does not exist: %s
- Cannot create namespace %s. Namespace already exists
- Namespace %s is not empty. Contains %d child namespace(s).
- Cannot create namespace %s because it already exists in Glue
- Glue does not support nested namespace, cannot list namespac
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/6133bfdae8e188c3.
Report an issue: GitHub.