{"record":{"id":"a3164f2e5a7999d4","repo":"apache/iceberg","slug":"e-wrapped-nosuchnamespaceexception","errorCode":null,"errorMessage":"e (wrapped NoSuchNamespaceException)","messagePattern":"e \\(wrapped NoSuchNamespaceException\\)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/SparkSessionCatalog.java","lineNumber":436,"sourceCode":"  @Override\n  public UnboundFunction loadFunction(Identifier ident) throws NoSuchFunctionException {\n    try {\n      return super.loadFunction(ident);\n    } catch (NoSuchFunctionException e) {\n      return getSessionCatalog().loadFunction(ident);\n    }\n  }\n\n  @Override\n  public Identifier[] listViews(String... namespace) {\n    try {\n      if (null != asViewCatalog) {\n        return asViewCatalog.listViews(namespace);\n      } else if (isViewCatalog()) {\n        return getSessionCatalog().listViews(namespace);\n      }\n    } catch (NoSuchNamespaceException e) {\n      throw new RuntimeException(e);\n    }\n\n    return new Identifier[0];\n  }\n\n  @Override\n  public boolean viewExists(Identifier ident) {\n    return (asViewCatalog != null && asViewCatalog.viewExists(ident))\n        || (isViewCatalog() && getSessionCatalog().viewExists(ident));\n  }\n\n  @Override\n  public View loadView(Identifier ident) throws NoSuchViewException {\n    if (null != asViewCatalog && asViewCatalog.viewExists(ident)) {\n      return asViewCatalog.loadView(ident);\n    } else if (isViewCatalog() && getSessionCatalog().viewExists(ident)) {\n      return getSessionCatalog().loadView(ident);\n    }","sourceCodeStart":418,"sourceCodeEnd":454,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/SparkSessionCatalog.java#L418-L454","documentation":"In SparkSessionCatalog.listViews, a NoSuchNamespaceException from the underlying view catalog is caught and rethrown wrapped in a plain RuntimeException. It means the namespace passed to listViews does not exist in any configured view catalog.","triggerScenarios":"Calling SHOW VIEWS (or listViews directly) on a namespace that does not exist in the delegate or Iceberg view catalog.","commonSituations":"Typo in namespace/database name; querying views in a database that was dropped; Spark resolving an unqualified namespace against the session catalog that lacks it.","solutions":["Verify the namespace exists: SHOW NAMESPACES IN <catalog> before listing views.","Create the namespace first (CREATE NAMESPACE) if it is missing.","Catch NoSuchNamespaceException upstream instead of relying on the wrapped RuntimeException, or check isViewCatalog support."],"exampleFix":"// before\nSHOW VIEWS IN prod.wrongdb\n// after\nCREATE NAMESPACE IF NOT EXISTS prod.db;\nSHOW VIEWS IN prod.db","handlingStrategy":"validation","validationCode":"Namespace ns = Namespace.of(\"prod\", \"db\");\nif (!catalog.namespaceExists(ns)) { throw new IllegalArgumentException(\"namespace missing: \" + ns); }","typeGuard":null,"tryCatchPattern":"try { catalog.listViews(ns); } catch (RuntimeException e) { if (e.getCause() instanceof NoSuchNamespaceException) { /* create namespace or fix name */ } else throw e; }","preventionTips":["Validate namespaces with SHOW NAMESPACES before listing views.","Create namespaces idempotently with CREATE NAMESPACE IF NOT EXISTS during setup.","Catch NoSuchNamespaceException at the caller level since the wrapper rethrows it as a RuntimeException."],"tags":["spark","catalog","namespace","views"],"backgroundTag":"directory-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"}