apache/iceberg · error · NoSuchNamespaceException

NoSuchNamespaceException(ident.namespace())

Error message

NoSuchNamespaceException(ident.namespace())

What it means

After the view commit, Iceberg's NoSuchNamespaceException is translated into Spark's NoSuchNamespaceException for the identifier's namespace. It means the view operation targeted a namespace that does not exist in the catalog.

Solutions

  1. Create the namespace first: CREATE NAMESPACE db;
  2. Verify namespace existence with SHOW NAMESPACES IN catalog
  3. Fix spelling/casing of the namespace in the view identifier

Example fix

// before
CREATE VIEW sales.v1 AS SELECT ...
// after
CREATE NAMESPACE IF NOT EXISTS sales;
CREATE VIEW sales.v1 AS SELECT ...
Defensive patterns

Strategy: try-catch

Validate before calling

if (Arrays.stream(catalog.listNamespaces()).noneMatch(n -> Arrays.equals(n.levels(), ident.namespace()))) {
  catalog.createNamespace(Namespace.of(ident.namespace()));
}

Try / catch

try { spark.sql("CREATE VIEW cat.db.v AS SELECT ..."); }
catch (NoSuchNamespaceException e) { spark.sql("CREATE NAMESPACE cat.db"); /* retry */ }

Prevention

When it happens

Trigger: CREATE OR REPLACE VIEW db.v ... where namespace db was never created or was dropped concurrently.

Common situations: Typo in schema/namespace name; running CREATE VIEW before CREATE DATABASE/NAMESPACE; concurrent drops in shared catalogs.

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

Appendix: source

Thrown at spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java:676

          icebergView = builder.replace();
          break;
        case CREATE_OR_REPLACE:
          Pair<Set<String>, org.apache.iceberg.view.View> replacement =
              createOrReplaceView(viewIdentifier, builder);
          replacedProperties = replacement.first();
          icebergView = replacement.second();
          break;
        default:
          throw new IllegalArgumentException("Unsupported view commit operation: " + viewCommit);
      }

      if (replacedProperties != null) {
        removeDroppedViewProperties(icebergView, replacedProperties, props.keySet());
      }

      return SparkView.toView(catalogName, icebergView);
    } catch (org.apache.iceberg.exceptions.NoSuchNamespaceException e) {
      throw new NoSuchNamespaceException(ident.namespace());
    } catch (AlreadyExistsException e) {
      if (viewCommit == ViewCommit.REPLACE && tableExists(ident)) {
        throw new NoSuchViewException(ident);
      } else if (viewCommit == ViewCommit.REPLACE) {
        // A table collision was handled above. Spark has no equivalent exception for other
        // Iceberg replacement conflicts, so preserve the original failure.
        throw e;
      }

      throw new ViewAlreadyExistsException(ident);
    } catch (org.apache.iceberg.exceptions.NoSuchViewException e) {
      throw new NoSuchViewException(ident);
    }
  }

  private Pair<Set<String>, org.apache.iceberg.view.View> createOrReplaceView(
      TableIdentifier viewIdentifier, ViewBuilder builder) {
    try {

View on GitHub (pinned to 86d9c8fc54)