apache/iceberg · error · NoSuchNamespaceException

Glue does not support nested namespace, cannot list namespac

Error message

Glue does not support nested namespace, cannot list namespaces under %s

What it means

GlueCatalog.listNamespaces throws NoSuchNamespaceException when asked to list sub-namespaces under a non-empty namespace. Glue databases are flat — there is no hierarchy — so any listing of a nested level is invalid, and if the given (single-level) namespace itself doesn't exist the call fails.

Source

Thrown at aws/src/main/java/org/apache/iceberg/aws/glue/GlueCatalog.java:490

              .databaseInput(
                  IcebergToGlueConverter.toDatabaseInput(
                      namespace, metadata, awsProperties.glueCatalogSkipNameValidation()))
              .build());
      LOG.info("Created namespace: {}", namespace);
    } catch (software.amazon.awssdk.services.glue.model.AlreadyExistsException e) {
      throw new AlreadyExistsException(
          "Cannot create namespace %s because it already exists in Glue", namespace);
    }
  }

  @Override
  public List<Namespace> listNamespaces(Namespace namespace) throws NoSuchNamespaceException {
    if (!namespace.isEmpty()) {
      // if it is not a list all op, just check if the namespace exists and return empty.
      if (namespaceExists(namespace)) {
        return Lists.newArrayList();
      }
      throw new NoSuchNamespaceException(
          "Glue does not support nested namespace, cannot list namespaces under %s", namespace);
    }

    // should be safe to list all before returning the list, instead of dynamically load the list.
    String nextToken = null;
    List<Namespace> results = Lists.newArrayList();
    do {
      GetDatabasesResponse response =
          glue.getDatabases(
              GetDatabasesRequest.builder()
                  .catalogId(awsProperties.glueCatalogId())
                  .nextToken(nextToken)
                  .build());
      nextToken = response.nextToken();
      if (response.hasDatabaseList()) {
        results.addAll(
            response.databaseList().stream()
                .map(GlueToIcebergConverter::toNamespace)

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Call listNamespaces with an empty namespace to list all top-level Glue databases, and never recurse into sub-namespaces with Glue.
  2. Verify the namespace you pass is a single-level name that exists (`namespaceExists`) before listing under it.
  3. Refactor code that assumes hierarchical namespaces to use flat names (e.g. underscores) when targeting Glue.

Example fix

// before
for (Namespace child : catalog.listNamespaces(ns)) { ... } // recursive listing

// after
if (ns.isEmpty()) {
  List<Namespace> all = catalog.listNamespaces(); // top-level only
}
// Glue namespaces are flat: do not list under a non-empty namespace
Defensive patterns

Strategy: validation

Validate before calling

if (!ns.isEmpty()) {
  // Glue is flat: never list sub-namespaces
  if (!catalog.namespaceExists(ns)) {
    throw new IllegalArgumentException("Namespace " + ns + " does not exist in Glue");
  }
}

Try / catch

try {
  return catalog.listNamespaces(ns);
} catch (NoSuchNamespaceException e) {
  LOG.warn("Glue is flat, cannot list under {}: {}", ns, e.getMessage());
  return List.of();
}

Prevention

When it happens

Trigger: Calling catalog.listNamespaces(Namespace.of("a","b")) (a multi-level namespace) — Glue can never have nested namespaces; or calling it with a one-level namespace that does not exist as a Glue database.

Common situations: Generic catalog exploration code that recursively lists namespaces (works on Hadoop/Hive catalogs but not Glue); assuming SQL-style `db.schema.table` three-part names; migrating code from another catalog implementation without adapting namespace handling.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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