apache/iceberg · error · NamespaceNotEmptyException

Namespace %s is not empty

Error message

Namespace %s is not empty

What it means

NamespaceNotEmptyException thrown by EcsCatalog.dropNamespace when the namespace still contains sub-namespaces or tables. ECS namespaces are marker objects, so the catalog refuses to drop a parent while children exist.

Source

Thrown at dell/src/main/java/org/apache/iceberg/dell/ecs/EcsCatalog.java:342

    if (!objectMetadata(namespaceObject).isPresent()) {
      throw new NoSuchNamespaceException(
          "Namespace %s(%s) properties object is absent", namespace, namespaceObject);
    }

    Map<String, String> result = loadProperties(namespaceObject).content();

    LOG.debug("Loaded metadata for namespace {} found {}", namespace, result);
    return result;
  }

  @Override
  public boolean dropNamespace(Namespace namespace) throws NamespaceNotEmptyException {
    if (!namespace.isEmpty() && !namespaceExists(namespace)) {
      throw new NoSuchNamespaceException("Namespace %s does not exist", namespace);
    }

    if (!listNamespaces(namespace).isEmpty() || !listTables(namespace).isEmpty()) {
      throw new NamespaceNotEmptyException("Namespace %s is not empty", namespace);
    }

    EcsURI namespaceObject = namespaceURI(namespace);
    client.deleteObject(namespaceObject.bucket(), namespaceObject.name());
    LOG.info("Dropped namespace: {}", namespace);
    return true;
  }

  @Override
  public boolean setProperties(Namespace namespace, Map<String, String> properties)
      throws NoSuchNamespaceException {
    return updateProperties(namespace, r -> r.putAll(properties));
  }

  @Override
  public boolean removeProperties(Namespace namespace, Set<String> properties)
      throws NoSuchNamespaceException {
    return updateProperties(namespace, r -> r.keySet().removeAll(properties));

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Drop all tables with listTables + dropTable first
  2. Drop sub-namespaces recursively before the parent
  3. Clean orphaned ECS objects if children no longer exist logically

Example fix

// before
catalog.dropNamespace(ns);
// after
for (TableIdentifier t : catalog.listTables(ns)) { catalog.dropTable(t); }
for (Namespace child : catalog.listNamespaces(ns)) { catalog.dropNamespace(child); }
catalog.dropNamespace(ns);
Defensive patterns

Strategy: validation

Validate before calling

boolean empty = catalog.listNamespaces(ns).isEmpty() && catalog.listTables(ns).isEmpty();
if (empty) { catalog.dropNamespace(ns); }

Try / catch

try { catalog.dropNamespace(ns); } catch (NamespaceNotEmptyException e) { /* purge children first */ }

Prevention

When it happens

Trigger: Calling dropNamespace on a namespace whose listNamespaces or listTables results are non-empty.

Common situations: Recursive cleanup that forgot to drop child tables first, tables created by another engine under the namespace, leftover orphan table objects in ECS.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


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