{"record":{"id":"8efa3f1931371412","repo":"apache/iceberg","slug":"namespace-does-not-exist-namespace","errorCode":null,"errorMessage":"Namespace does not exist: namespace","messagePattern":"Namespace does not exist: namespace","errorType":"exception","errorClass":"NoSuchNamespaceException","httpStatus":404,"severity":"error","filePath":"spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java","lineNumber":568,"sourceCode":"          asNamespaceCatalog.removeProperties(Namespace.of(namespace), removals);\n        }\n\n      } catch (org.apache.iceberg.exceptions.NoSuchNamespaceException e) {\n        throw new NoSuchNamespaceException(namespace);\n      }\n    } else {\n      throw new NoSuchNamespaceException(namespace);\n    }\n  }\n\n  @Override\n  public boolean dropNamespace(String[] namespace, boolean cascade)\n      throws NoSuchNamespaceException {\n    if (asNamespaceCatalog != null) {\n      try {\n        return asNamespaceCatalog.dropNamespace(Namespace.of(namespace));\n      } catch (org.apache.iceberg.exceptions.NoSuchNamespaceException e) {\n        throw new NoSuchNamespaceException(namespace);\n      }\n    }\n\n    return false;\n  }\n\n  @Override\n  public Identifier[] listViews(String... namespace) {\n    if (null != asViewCatalog) {\n      return asViewCatalog.listViews(Namespace.of(namespace)).stream()\n          .map(ident -> Identifier.of(ident.namespace().levels(), ident.name()))\n          .toArray(Identifier[]::new);\n    }\n\n    return new Identifier[0];\n  }\n\n  @Override","sourceCodeStart":550,"sourceCodeEnd":586,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java#L550-L586","documentation":"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.","triggerScenarios":"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.","commonSituations":"Drop scripts run twice; dropping namespaces in the wrong catalog/environment; concurrent jobs dropping the same namespace.","solutions":["Use DROP NAMESPACE IF EXISTS <catalog>.<ns>","Check catalog.namespaceExists(namespace) before dropping","Verify you are targeting the intended catalog configuration"],"exampleFix":"// before\nspark.sql(\"DROP NAMESPACE prod.tmp_staging\");\n// after\nspark.sql(\"DROP NAMESPACE IF EXISTS prod.tmp_staging\");","handlingStrategy":"validation","validationCode":"if (catalog.namespaceExists(namespace)) {\n  catalog.dropNamespace(namespace, cascade);\n} // otherwise nothing to do","typeGuard":null,"tryCatchPattern":"try {\n  catalog.dropNamespace(namespace, cascade);\n} catch (NoSuchNamespaceException e) {\n  // already gone; treat as success in cleanup jobs\n}","preventionTips":["Use DROP NAMESPACE IF EXISTS in SQL scripts","Make teardown scripts idempotent","Confirm target catalog/environment before destructive DDL"],"tags":["spark","namespace","drop"],"backgroundTag":"entity-not-found","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}