apache/iceberg · error · NoSuchNamespaceException

Namespace does not exist:

Error message

Namespace does not exist: 

What it means

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.

Source

Thrown at spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/SupportsFunctions.java:48

  default boolean isFunctionNamespace(String[] namespace) {
    return namespace.length == 0;
  }

  default boolean isExistingNamespace(String[] namespace) {
    return namespace.length == 0;
  }

  @Override
  default Identifier[] listFunctions(String[] namespace) throws NoSuchNamespaceException {
    if (isFunctionNamespace(namespace)) {
      return SparkFunctions.list().stream()
          .map(name -> Identifier.of(namespace, name))
          .toArray(Identifier[]::new);
    } else if (isExistingNamespace(namespace)) {
      return new Identifier[0];
    }

    throw new NoSuchNamespaceException(namespace);
  }

  @Override
  default UnboundFunction loadFunction(Identifier ident) throws NoSuchFunctionException {
    String[] namespace = ident.namespace();
    String name = ident.name();

    if (isFunctionNamespace(namespace)) {
      UnboundFunction func = SparkFunctions.load(name);
      if (func != null) {
        return func;
      }
    }

    throw new NoSuchFunctionException(ident);
  }
}

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Verify the namespace exists via listNamespaces before calling listFunctions
  2. Correct the namespace identifier (spelling, case, hierarchy depth)
  3. Catch NoSuchNamespaceException and return an empty result or a clear user-facing message

Example fix

// before
Identifier[] fns = catalog.listFunctions(Identifier.of(new String[] {"prod", "fn"})); // throws
// after
if (catalog.namespaceExists(Identifier.of(new String[] {"prod", "fn"}))) {
  fns = catalog.listFunctions(Identifier.of(new String[] {"prod", "fn"}));
} else {
  fns = new Identifier[0];
}
Defensive patterns

Strategy: try-catch

Validate before calling

boolean nsExists = catalog.namespaceExists(Identifier.of(namespace));
if (!nsExists) {
  LOG.warn("Skipping function listing: namespace {} does not exist", Arrays.toString(namespace));
}

Type guard

boolean namespaceExists(Catalog catalog, Identifier ident) {
  try {
    catalog.listNamespaces(ident.namespace());
    return true;
  } catch (NoSuchNamespaceException e) {
    return false;
  }
}

Try / catch

try {
  functions = catalog.listFunctions(Identifier.of(namespace));
} catch (NoSuchNamespaceException e) {
  LOG.warn("Namespace {} does not exist", Arrays.toString(namespace));
  functions = new Identifier[0];
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

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


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/7fae2fda8267af1d. Report an issue: GitHub.