apache/iceberg · error · NoSuchNamespaceException

fail to find Glue database for namespace %s, error message:

Error message

fail to find Glue database for namespace %s, error message: %s

What it means

GlueCatalog.loadNamespaceMetadata catches EntityNotFoundException from Glue's GetDatabase and rethrows it as NoSuchNamespaceException. It means no Glue database exists for the given namespace in the configured catalog ID, so Iceberg cannot load its metadata.

Source

Thrown at aws/src/main/java/org/apache/iceberg/aws/glue/GlueCatalog.java:549

      Map<String, String> result = Maps.newHashMap(database.parameters());

      if (database.locationUri() != null) {
        result.put(
            IcebergToGlueConverter.GLUE_DB_LOCATION_KEY,
            LocationUtil.stripTrailingSlash(database.locationUri()));
      }

      if (database.description() != null) {
        result.put(IcebergToGlueConverter.GLUE_DESCRIPTION_KEY, database.description());
      }

      LOG.debug("Loaded metadata for namespace {} found {}", namespace, result);
      return result;
    } catch (InvalidInputException e) {
      throw new NoSuchNamespaceException(
          "invalid input for namespace %s, error message: %s", namespace, e.getMessage());
    } catch (EntityNotFoundException e) {
      throw new NoSuchNamespaceException(
          "fail to find Glue database for namespace %s, error message: %s",
          databaseName, e.getMessage());
    }
  }

  @Override
  public boolean dropNamespace(Namespace namespace) throws NamespaceNotEmptyException {
    namespaceExists(namespace);

    GetTablesResponse response =
        glue.getTables(
            GetTablesRequest.builder()
                .catalogId(awsProperties.glueCatalogId())
                .databaseName(
                    IcebergToGlueConverter.toDatabaseName(
                        namespace, awsProperties.glueCatalogSkipNameValidation()))
                .build());

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Check `catalog.namespaceExists(ns)` first, or create the namespace with createNamespace if missing.
  2. Fix the namespace spelling and confirm it matches the Glue database name exactly.
  3. Verify glueCatalogId / region configuration matches where the database actually exists.
  4. Confirm IAM permissions allow glue:GetDatabase — denied access can manifest as not-found.

Example fix

// before
Map<String, String> meta = catalog.loadNamespaceMetadata(Namespace.of("sales"));

// after
Namespace ns = Namespace.of("sales");
if (!catalog.namespaceExists(ns)) {
  catalog.createNamespace(ns);
}
Map<String, String> meta = catalog.loadNamespaceMetadata(ns);
Defensive patterns

Strategy: try-catch

Validate before calling

Namespace ns = Namespace.of("sales");
if (!catalog.namespaceExists(ns)) {
  catalog.createNamespace(ns);
}

Try / catch

try {
  return catalog.loadNamespaceMetadata(ns);
} catch (NoSuchNamespaceException e) {
  LOG.error("Glue database for {} not found; check name, region, catalogId and IAM", ns);
  throw e;
}

Prevention

When it happens

Trigger: Calling loadNamespaceMetadata(Namespace.of("db")) where `db` was never created, was dropped, exists in another account/region than awsProperties.glueCatalogId, or the caller lacks Glue IAM permissions so the database appears absent.

Common situations: Environment mismatch (dev vs prod Glue catalogs); typos in namespace names; another pipeline dropped the database; assuming the catalog auto-creates namespaces when it does not.

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/c254458d46eecdd2. Report an issue: GitHub.