{"record":{"id":"7fae2fda8267af1d","repo":"apache/iceberg","slug":"namespace-does-not-exist","errorCode":null,"errorMessage":"Namespace does not exist: ","messagePattern":"Namespace does not exist: ","errorType":"exception","errorClass":"NoSuchNamespaceException","httpStatus":null,"severity":"error","filePath":"spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/SupportsFunctions.java","lineNumber":48,"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(ident);\n  }\n}\n","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/SupportsFunctions.java#L30-L66","documentation":"SupportsFunctions.listFunctions resolves functions for a namespace: if the namespace exists (or is the top-level empty namespace) it returns function identifiers (or an empty array for an existing but function-less namespace); otherwise it throws NoSuchNamespaceException(\"Namespace does not exist: \" + namespace). It signals the caller referenced a namespace that the catalog does not know about.","triggerScenarios":"Calling listFunctions (or SHOW FUNCTIONS-style Spark commands backed by this catalog) with a namespace array that does not match any existing namespace in the catalog - e.g. a typo, a dropped namespace, or a wrongly-scoped multi-part namespace.","commonSituations":"Spark SQL commands like SHOW FUNCTIONS IN <ns> against a non-existent namespace; catalogs where the namespace hierarchy differs from what the SQL text assumes; stale references after the namespace was dropped.","solutions":["Verify the namespace exists via listNamespaces before calling listFunctions","Correct the namespace identifier (spelling, case, hierarchy depth)","Catch NoSuchNamespaceException and return an empty result or a clear user-facing message"],"exampleFix":"// before\nIdentifier[] fns = catalog.listFunctions(Identifier.of(new String[] {\"prod\", \"fn\"})); // throws\n// after\nif (catalog.namespaceExists(Identifier.of(new String[] {\"prod\", \"fn\"}))) {\n  fns = catalog.listFunctions(Identifier.of(new String[] {\"prod\", \"fn\"}));\n} else {\n  fns = new Identifier[0];\n}","handlingStrategy":"try-catch","validationCode":"boolean nsExists = catalog.namespaceExists(Identifier.of(namespace));\nif (!nsExists) {\n  LOG.warn(\"Skipping function listing: namespace {} does not exist\", Arrays.toString(namespace));\n}","typeGuard":"boolean namespaceExists(Catalog catalog, Identifier ident) {\n  try {\n    catalog.listNamespaces(ident.namespace());\n    return true;\n  } catch (NoSuchNamespaceException e) {\n    return false;\n  }\n}","tryCatchPattern":"try {\n  functions = catalog.listFunctions(Identifier.of(namespace));\n} catch (NoSuchNamespaceException e) {\n  LOG.warn(\"Namespace {} does not exist\", Arrays.toString(namespace));\n  functions = new Identifier[0];\n}","preventionTips":["Call listNamespaces to confirm the namespace before listing functions","Normalize namespace case and hierarchy depth to match the catalog's layout","Handle NoSuchNamespaceException explicitly in SHOW FUNCTIONS-style SQL paths","Check for recently dropped namespaces in stale sessions"],"tags":["spark","catalog","namespace","not-found"],"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-14T16:17:12.679Z"}