{"record":{"id":"9d0919b25d2e88ee","repo":"apache/iceberg","slug":"no-such-namespace-s","errorCode":null,"errorMessage":"No such namespace: %s","messagePattern":"No such namespace: (.+?)","errorType":"exception","errorClass":"org.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException","httpStatus":null,"severity":"error","filePath":"spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java","lineNumber":477,"sourceCode":"  public String[][] listNamespaces() {\n    if (asNamespaceCatalog != null) {\n      return asNamespaceCatalog.listNamespaces().stream()\n          .map(Namespace::levels)\n          .toArray(String[][]::new);\n    }\n\n    return new String[0][];\n  }\n\n  @Override\n  public String[][] listNamespaces(String[] namespace) throws NoSuchNamespaceException {\n    if (asNamespaceCatalog != null) {\n      try {\n        return asNamespaceCatalog.listNamespaces(Namespace.of(namespace)).stream()\n            .map(Namespace::levels)\n            .toArray(String[][]::new);\n      } catch (org.apache.iceberg.exceptions.NoSuchNamespaceException e) {\n        throw new NoSuchNamespaceException(namespace);\n      }\n    }\n\n    throw new NoSuchNamespaceException(namespace);\n  }\n\n  @Override\n  public boolean namespaceExists(String[] namespace) {\n    return asNamespaceCatalog != null\n        && asNamespaceCatalog.namespaceExists(Namespace.of(namespace));\n  }\n\n  @Override\n  public Map<String, String> loadNamespaceMetadata(String[] namespace)\n      throws NoSuchNamespaceException {\n    if (asNamespaceCatalog != null) {\n      try {\n        return asNamespaceCatalog.loadNamespaceMetadata(Namespace.of(namespace));","sourceCodeStart":459,"sourceCodeEnd":495,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java#L459-L495","documentation":"listNamespaces(namespace) lists child namespaces of the given namespace; if the parent namespace itself does not exist in an Iceberg namespace-capable catalog, NoSuchNamespaceException is converted to Spark's NoSuchNamespaceException at line 477. The same error is thrown when the catalog does not support namespaces at all.","triggerScenarios":"SHOW NAMESPACES IN nonexistentNamespace; spark.catalog().listNamespaces(\"missing\") on a namespace that does not exist; calling listNamespaces on a catalog that is not a SupportsNamespaces instance (unconditional throw after the null check).","commonSituations":"Typo'd namespace in SHOW NAMESPACES / USE statements; querying a namespace in a named catalog configured against the wrong warehouse; catalogs (e.g., simple Hadoop file catalogs) whose backing directory was removed; using a catalog that lacks namespace support.","solutions":["Verify the namespace exists (SHOW NAMESPACES IN catalog; list the warehouse location).","Create the namespace first: CREATE NAMESPACE catalog.db (or CREATE DATABASE).","Check spark.sql.catalog.<name>.warehouse / catalog config for the correct root path.","Catch NoSuchNamespaceException and return an empty list in exploratory tooling."],"exampleFix":"// before\nspark.sql(\"SHOW NAMESPACES IN iceberg_cat.db\")\n// after\nspark.sql(\"CREATE NAMESPACE IF NOT EXISTS iceberg_cat.db\");\nspark.sql(\"SHOW NAMESPACES IN iceberg_cat.db\")","handlingStrategy":"try-catch","validationCode":"boolean exists = Arrays.stream(spark.sessionState().catalogManager().catalog(name).asNamespaceCatalog().orElseThrow().listNamespaces()).anyMatch(ns -> Arrays.equals(ns.levels(), levels));","typeGuard":"null","tryCatchPattern":"try { catalog.listNamespaces(ns); } catch (NoSuchNamespaceException e) { /* create namespace or return empty */ }","preventionTips":["CREATE NAMESPACE before querying children.","Validate namespace names in job configs.","Confirm the catalog supports namespaces (SupportsNamespaces)."],"tags":["spark","namespace","catalog","not-found"],"backgroundTag":"directory-not-found","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}