{"record":{"id":"2ef8826246952455","repo":"apache/iceberg","slug":"nosuchnamespaceexception-namespace","errorCode":null,"errorMessage":"NoSuchNamespaceException(namespace)","messagePattern":"NoSuchNamespaceException\\(namespace\\)","errorType":"exception","errorClass":"NoSuchNamespaceException","httpStatus":null,"severity":"error","filePath":"spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/SupportsFunctions.java","lineNumber":49,"sourceCode":"  default boolean isFunctionNamespace(String[] namespace) {\n    return namespace.length == 0;\n  }\n\n  default boolean isExistingNamespace(String[] namespace) {\n    return namespace.length == 0;\n  }\n\n  @Override\n  default Identifier[] listFunctions(String[] namespace) throws NoSuchNamespaceException {\n    if (isFunctionNamespace(namespace)) {\n      return SparkFunctions.list().stream()\n          .map(name -> Identifier.of(namespace, name))\n          .toArray(Identifier[]::new);\n    } else if (isExistingNamespace(namespace)) {\n      return new Identifier[0];\n    }\n\n    throw new NoSuchNamespaceException(namespace);\n  }\n\n  @Override\n  default UnboundFunction loadFunction(Identifier ident) throws NoSuchFunctionException {\n    String[] namespace = ident.namespace();\n    String name = ident.name();\n\n    if (isFunctionNamespace(namespace)) {\n      UnboundFunction func = SparkFunctions.load(name);\n      if (func != null) {\n        return func;\n      }\n    }\n\n    throw new NoSuchFunctionException(\n        String.format(\"Cannot load function: %s.%s\", name(), ident), Option.empty());\n  }\n}","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/SupportsFunctions.java#L31-L67","documentation":"SupportsFunctions.listFunctions() returns function identifiers for a namespace; if the namespace neither exists nor contains functions, it throws NoSuchNamespaceException(namespace). The catalog adapter signals that the given multi-part namespace (database/schema path) is unknown to the underlying catalog.","triggerScenarios":"Calling listFunctions(Identifier) with a namespace array that does not match any existing namespace in the catalog — e.g. listFunctions(Identifier.of(new String[]{\"no_such_db\"}, \"*\")) or a mistyped schema name in SQL SHOW FUNCTIONS IN db.","commonSituations":"Typos in schema/database names in Spark SQL; querying functions under a namespace in a catalog where it was dropped or never created; cross-catalog confusion (namespace exists in another catalog).","solutions":["Verify the namespace exists with catalog.namespaceExists(Identifier.of(namespace)) or SHOW NAMESPACES before listing functions","Correct the namespace spelling/parts in the identifier or SQL statement","Catch NoSuchNamespaceException and surface a user-friendly 'unknown namespace' message"],"exampleFix":"// before\nIdentifier[] fns = catalog.listFunctions(Identifier.of(new String[]{\"mydb\"}));\n// after\nIdentifier ns = Identifier.of(new String[]{\"mydb\"});\nif (catalog.namespaceExists(ns)) {\n  Identifier[] fns = catalog.listFunctions(ns);\n}","handlingStrategy":"try-catch","validationCode":"if (!catalog.namespaceExists(Identifier.of(namespace))) {\n  throw new IllegalArgumentException(\"Namespace does not exist: \" + String.join(\".\", namespace));\n}","typeGuard":"boolean namespaceExists = false;\ntry { catalog.listNamespaces(Identifier.of(Arrays.copyOf(namespace, namespace.length - 1))).contains(namespace[namespace.length - 1]); namespaceExists = true; } catch (NoSuchNamespaceException ignored) {}","tryCatchPattern":"try {\n  return catalog.listFunctions(Identifier.of(namespace));\n} catch (NoSuchNamespaceException e) {\n  throw new IllegalArgumentException(\"Unknown namespace: \" + String.join(\".\", namespace), e);\n}","preventionTips":["Call namespaceExists or listNamespaces before listing functions","Validate multi-part namespace spelling, especially across multiple catalogs","Handle NoSuchNamespaceException in SQL error reporting for SHOW FUNCTIONS IN <db>"],"tags":["spark","catalog","namespace"],"backgroundTag":"resource-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"}