{"record":{"id":"02e83bd493f3ac20","repo":"apache/iceberg","slug":"nosuchtableexception-ident-02e83b","errorCode":null,"errorMessage":"NoSuchTableException(ident)","messagePattern":"NoSuchTableException\\(ident\\)","errorType":"exception","errorClass":"NoSuchTableException","httpStatus":404,"severity":"error","filePath":"spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java","lineNumber":941,"sourceCode":"    if (identifier instanceof PathIdentifier) {\n      throw new IllegalArgumentException(\n          String.format(\n              \"Cannot pass path based identifier to %s method. %s is a path.\", method, identifier));\n    }\n  }\n\n  private Table load(Identifier ident, TimeTravel timeTravel) throws NoSuchTableException {\n    if (isPathIdentifier(ident)) {\n      return loadPath((PathIdentifier) ident, timeTravel);\n    }\n\n    try {\n      org.apache.iceberg.Table table = icebergCatalog.loadTable(buildIdentifier(ident));\n      return SparkTable.create(table, timeTravel);\n\n    } catch (org.apache.iceberg.exceptions.NoSuchTableException e) {\n      if (ident.namespace().length == 0) {\n        throw new NoSuchTableException(ident);\n      }\n\n      // if the original load didn't work, try using the namespace as an identifier because\n      // the original identifier may include a snapshot selector or may point to the changelog\n      TableIdentifier namespaceAsIdent = buildIdentifier(namespaceToIdentifier(ident.namespace()));\n      org.apache.iceberg.Table table;\n      try {\n        table = icebergCatalog.loadTable(namespaceAsIdent);\n      } catch (Exception ignored) {\n        // the namespace does not identify a table, so it cannot be a table with a snapshot selector\n        // throw an exception for the original identifier\n        throw new NoSuchTableException(ident);\n      }\n\n      // loading the namespace as a table worked, check the name to see if it is a valid selector\n      // or if the name points to the changelog\n\n      if (ident.name().equalsIgnoreCase(SparkChangelogTable.TABLE_NAME)) {","sourceCodeStart":923,"sourceCodeEnd":959,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java#L923-L959","documentation":"Spark's NoSuchTableException thrown from the load path when the identifier has an empty namespace and the Iceberg catalog reports no table. Because there is no namespace to reinterpret as a table identifier (snapshot-selector fallback), Spark immediately surfaces the original failure as NoSuchTableException for the identifier.","triggerScenarios":"catalog.loadTable(Identifier of single name) where icebergCatalog.loadTable throws NoSuchTableException and ident.namespace().length == 0 — i.e., referencing just 'tablename' with no database and no such table at the catalog root.","commonSituations":"Forgetting the database/namespace qualifier; using the wrong catalog name in spark.sql.catalog config; table dropped or never created; current namespace not set in the session.","solutions":["Qualify the table with its namespace: USE db; or SELECT * FROM catalog.db.table","Verify the table exists with SHOW TABLES IN catalog.db","Check the spark.sql.catalog.<name> wiring points at the intended warehouse","Set the session catalog/current namespace so single-part names resolve"],"exampleFix":"// before\nSELECT * FROM local.events; // no namespace, table not found\n// after\nSELECT * FROM local.db.events;","handlingStrategy":"validation","validationCode":"if (ident.namespace().length == 0 || !spark.catalog().tableExists(ident.namespace(), ident.name())) { /* qualify or fix the name */ }","typeGuard":null,"tryCatchPattern":"try {\n  Table t = catalog.loadTable(ident);\n} catch (NoSuchTableException e) {\n  // use a namespace-qualified identifier\n}","preventionTips":["Always use fully-qualified catalog.namespace.table names","USE the namespace or set currentNamespace before single-part queries","Verify table existence with SHOW TABLES after DDL"],"tags":["spark","table","not-found","identifier"],"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"}