{"record":{"id":"1700098f1e099096","repo":"apache/iceberg","slug":"nosuchnamespaceexception-ident-namespace","errorCode":null,"errorMessage":"NoSuchNamespaceException(ident.namespace())","messagePattern":"NoSuchNamespaceException\\(ident\\.namespace\\(\\)\\)","errorType":"exception","errorClass":"NoSuchNamespaceException","httpStatus":404,"severity":"error","filePath":"spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java","lineNumber":676,"sourceCode":"          icebergView = builder.replace();\n          break;\n        case CREATE_OR_REPLACE:\n          Pair<Set<String>, org.apache.iceberg.view.View> replacement =\n              createOrReplaceView(viewIdentifier, builder);\n          replacedProperties = replacement.first();\n          icebergView = replacement.second();\n          break;\n        default:\n          throw new IllegalArgumentException(\"Unsupported view commit operation: \" + viewCommit);\n      }\n\n      if (replacedProperties != null) {\n        removeDroppedViewProperties(icebergView, replacedProperties, props.keySet());\n      }\n\n      return SparkView.toView(catalogName, icebergView);\n    } catch (org.apache.iceberg.exceptions.NoSuchNamespaceException e) {\n      throw new NoSuchNamespaceException(ident.namespace());\n    } catch (AlreadyExistsException e) {\n      if (viewCommit == ViewCommit.REPLACE && tableExists(ident)) {\n        throw new NoSuchViewException(ident);\n      } else if (viewCommit == ViewCommit.REPLACE) {\n        // A table collision was handled above. Spark has no equivalent exception for other\n        // Iceberg replacement conflicts, so preserve the original failure.\n        throw e;\n      }\n\n      throw new ViewAlreadyExistsException(ident);\n    } catch (org.apache.iceberg.exceptions.NoSuchViewException e) {\n      throw new NoSuchViewException(ident);\n    }\n  }\n\n  private Pair<Set<String>, org.apache.iceberg.view.View> createOrReplaceView(\n      TableIdentifier viewIdentifier, ViewBuilder builder) {\n    try {","sourceCodeStart":658,"sourceCodeEnd":694,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java#L658-L694","documentation":"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.","triggerScenarios":"CREATE OR REPLACE VIEW db.v ... where namespace db was never created or was dropped concurrently.","commonSituations":"Typo in schema/namespace name; running CREATE VIEW before CREATE DATABASE/NAMESPACE; concurrent drops in shared catalogs.","solutions":["Create the namespace first: CREATE NAMESPACE db;","Verify namespace existence with SHOW NAMESPACES IN catalog","Fix spelling/casing of the namespace in the view identifier"],"exampleFix":"// before\nCREATE VIEW sales.v1 AS SELECT ...\n// after\nCREATE NAMESPACE IF NOT EXISTS sales;\nCREATE VIEW sales.v1 AS SELECT ...","handlingStrategy":"try-catch","validationCode":"if (Arrays.stream(catalog.listNamespaces()).noneMatch(n -> Arrays.equals(n.levels(), ident.namespace()))) {\n  catalog.createNamespace(Namespace.of(ident.namespace()));\n}","typeGuard":null,"tryCatchPattern":"try { spark.sql(\"CREATE VIEW cat.db.v AS SELECT ...\"); }\ncatch (NoSuchNamespaceException e) { spark.sql(\"CREATE NAMESPACE cat.db\"); /* retry */ }","preventionTips":["Create namespaces before creating views in them","Idempotently provision namespaces in job setup","Validate namespace names against listNamespaces before DDL"],"tags":["spark","view","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-23T08:17:48.524Z"}