apache/iceberg · error · NoSuchNamespaceException
Namespace does not exist: namespace
Error message
Namespace does not exist: namespace
What it means
SparkCatalog.dropNamespace throws NoSuchNamespaceException when the underlying catalog's dropNamespace reports the namespace missing (converted from org.apache.iceberg.exceptions.NoSuchNamespaceException). Returned as Spark's 'Namespace does not exist: namespace' so DROP NAMESPACE fails instead of silently returning false.
Solutions
- Use DROP NAMESPACE IF EXISTS <catalog>.<ns>
- Check catalog.namespaceExists(namespace) before dropping
- Verify you are targeting the intended catalog configuration
Example fix
// before
spark.sql("DROP NAMESPACE prod.tmp_staging");
// after
spark.sql("DROP NAMESPACE IF EXISTS prod.tmp_staging"); Defensive patterns
Strategy: validation
Validate before calling
if (catalog.namespaceExists(namespace)) {
catalog.dropNamespace(namespace, cascade);
} // otherwise nothing to do Try / catch
try {
catalog.dropNamespace(namespace, cascade);
} catch (NoSuchNamespaceException e) {
// already gone; treat as success in cleanup jobs
} Prevention
- Use DROP NAMESPACE IF EXISTS in SQL scripts
- Make teardown scripts idempotent
- Confirm target catalog/environment before destructive DDL
When it happens
Trigger: DROP NAMESPACE <catalog>.<ns> (cascade or not) when the namespace does not exist in the backing catalog; also thrown by the wrapped catalog during cascade deletes when a child namespace is missing.
Common situations: Drop scripts run twice; dropping namespaces in the wrong catalog/environment; concurrent jobs dropping the same namespace.
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
- Cannot apply unknown namespace change
- Cannot apply unknown namespace change
- Cannot apply unknown namespace change
- Cannot apply unknown namespace change
- Cannot create table as the namespace does not exist
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/8efa3f1931371412.
Report an issue: GitHub.
Appendix: source
Thrown at spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java:568
asNamespaceCatalog.removeProperties(Namespace.of(namespace), removals);
}
} catch (org.apache.iceberg.exceptions.NoSuchNamespaceException e) {
throw new NoSuchNamespaceException(namespace);
}
} else {
throw new NoSuchNamespaceException(namespace);
}
}
@Override
public boolean dropNamespace(String[] namespace, boolean cascade)
throws NoSuchNamespaceException {
if (asNamespaceCatalog != null) {
try {
return asNamespaceCatalog.dropNamespace(Namespace.of(namespace));
} catch (org.apache.iceberg.exceptions.NoSuchNamespaceException e) {
throw new NoSuchNamespaceException(namespace);
}
}
return false;
}
@Override
public Identifier[] listViews(String... namespace) {
if (null != asViewCatalog) {
return asViewCatalog.listViews(Namespace.of(namespace)).stream()
.map(ident -> Identifier.of(ident.namespace().levels(), ident.name()))
.toArray(Identifier[]::new);
}
return new Identifier[0];
}
@OverrideView on GitHub (pinned to 86d9c8fc54)