{"record":{"id":"7ab8fd8917feade3","repo":"apache/iceberg","slug":"nosuchviewexception-ident","errorCode":null,"errorMessage":"NoSuchViewException(ident)","messagePattern":"NoSuchViewException\\(ident\\)","errorType":"exception","errorClass":"NoSuchViewException","httpStatus":null,"severity":"error","filePath":"spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java","lineNumber":599,"sourceCode":"          .toArray(Identifier[]::new);\n    }\n\n    return new Identifier[0];\n  }\n\n  @Override\n  public boolean viewExists(Identifier ident) {\n    return asViewCatalog != null && asViewCatalog.viewExists(buildIdentifier(ident));\n  }\n\n  @Override\n  public View loadView(Identifier ident) throws NoSuchViewException {\n    if (null != asViewCatalog) {\n      try {\n        org.apache.iceberg.view.View view = asViewCatalog.loadView(buildIdentifier(ident));\n        return new SparkView(catalogName, view);\n      } catch (org.apache.iceberg.exceptions.NoSuchViewException e) {\n        throw new NoSuchViewException(ident);\n      }\n    }\n\n    throw new NoSuchViewException(ident);\n  }\n\n  @Override\n  public View createView(ViewInfo viewInfo)\n      throws ViewAlreadyExistsException, NoSuchNamespaceException {\n    if (null != asViewCatalog && viewInfo != null) {\n      Identifier ident = viewInfo.ident();\n      String sql = viewInfo.sql();\n      String currentCatalog = viewInfo.currentCatalog();\n      String[] currentNamespace = viewInfo.currentNamespace();\n      StructType schema = viewInfo.schema();\n      String[] queryColumnNames = viewInfo.queryColumnNames();\n      Map<String, String> properties = viewInfo.properties();\n      Schema icebergSchema = SparkSchemaUtil.convert(schema);","sourceCodeStart":581,"sourceCodeEnd":617,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java#L581-L617","documentation":"loadView wraps the underlying ViewCatalog result: if loadView on the Iceberg view fails with NoSuchViewException it is rethrown as Spark's NoSuchViewException for the identifier. This final throw is the fallback when the wrapped catalog implements ViewCatalog (asViewCatalog != null) but the view was not found — Spark's analyzer uses it to decide a name is unresolvable.","triggerScenarios":"SELECT/DESCRIBE VIEW on catalog.db.view where asViewCatalog.loadView(buildIdentifier(ident)) throws org.apache.iceberg.exceptions.NoSuchViewException because no such view exists in the catalog; also the fall-through throw when asViewCatalog is null and loadView is invoked anyway.","commonSituations":"Referencing a view with the wrong name, wrong database, or wrong catalog prefix; querying a TABLE as a view (or vice versa) — Iceberg distinguishes tables and views; stale Spark session cache after the view was renamed/dropped; environment mismatch (view created in dev, query in prod).","solutions":["Confirm the view exists: SHOW VIEWS IN catalog.db, and check the fully qualified identifier (catalog.database.name)","Check you are loading a view, not a table with the same name — Iceberg keeps them in separate namespaces in the catalog","Refresh/replace the Spark session or clear catalog caches if the view was created recently by another job","Create the missing view (CREATE VIEW) if it should exist"],"exampleFix":"// before\nSELECT * FROM prod.reporting.daily_revenue; // NoSuchViewException\n// after\nSHOW VIEWS IN prod.reporting; // find correct name\nSELECT * FROM prod.reporting.daily_revenue_v2;","handlingStrategy":"try-catch","validationCode":"boolean viewExists = spark.sql(\"SHOW VIEWS IN \" + db).collectAsList().stream()\n    .anyMatch(r -> r.getString(0).equalsIgnoreCase(viewName));\nif (!viewExists) { /* create view or correct the reference */ }","typeGuard":null,"tryCatchPattern":"try {\n  View v = sparkCatalog.loadView(Identifier.of(new String[]{db}, viewName));\n} catch (org.apache.spark.sql.catalyst.analysis.NoSuchViewException e) {\n  // create the view or fall back to a table reference\n}","preventionTips":["Fully qualify view references (catalog.database.view) to avoid wrong-catalog lookups","Use SHOW VIEWS to distinguish views from tables sharing names","Drop and recreate views through one pipeline to avoid stale references","Confirm environment/catalog before querying"],"tags":["spark","view","catalog","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-14T16:17:12.679Z"}