{"record":{"id":"4e41923ba9239561","repo":"apache/iceberg","slug":"org-apache-iceberg-exceptions-nosuchtableexception-4e4192","errorCode":null,"errorMessage":"org.apache.iceberg.exceptions.NoSuchTableException: ","messagePattern":"org\\.apache\\.iceberg\\.exceptions\\.NoSuchTableException: ","errorType":"exception","errorClass":"NoSuchTableException","httpStatus":null,"severity":"error","filePath":"spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java","lineNumber":180,"sourceCode":"    return CatalogUtil.buildIcebergCatalog(name, optionsMap, conf);\n  }\n\n  /**\n   * Build an Iceberg {@link TableIdentifier} for the given Spark identifier.\n   *\n   * @param identifier Spark's identifier\n   * @return an Iceberg identifier\n   */\n  protected TableIdentifier buildIdentifier(Identifier identifier) {\n    return Spark3Util.identifierToTableIdentifier(identifier);\n  }\n\n  @Override\n  public Table loadTable(Identifier ident) throws NoSuchTableException {\n    try {\n      return load(ident);\n    } catch (org.apache.iceberg.exceptions.NoSuchTableException e) {\n      throw new NoSuchTableException(ident);\n    }\n  }\n\n  @Override\n  public Table loadTable(Identifier ident, String version) throws NoSuchTableException {\n    Table table = loadTable(ident);\n\n    if (table instanceof SparkTable) {\n      SparkTable sparkTable = (SparkTable) table;\n\n      Preconditions.checkArgument(\n          sparkTable.snapshotId() == null && sparkTable.branch() == null,\n          \"Cannot do time-travel based on both table identifier and AS OF\");\n\n      try {\n        return sparkTable.copyWithSnapshotId(Long.parseLong(version));\n      } catch (NumberFormatException e) {\n        SnapshotRef ref = sparkTable.table().refs().get(version);","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java#L162-L198","documentation":"SparkCatalog.loadTable wraps org.apache.iceberg.exceptions.NoSuchTableException from Catalog.loadTable into Spark's NoSuchTableException carrying the identifier. The underlying Iceberg catalog could not resolve the identifier to a table.","triggerScenarios":"Calling loadTable with a misspelled or non-existent table/namespace, a table dropped by another process, or a catalog pointed at the wrong warehouse/location.","commonSituations":"Typo in table name; stale Spark session after the table was dropped/recreated elsewhere; wrong warehouse path or catalog options so the metadata file is not found; case/namespace mismatches.","solutions":["Verify the table exists: SHOW TABLES IN <catalog>.<namespace> and check exact identifier casing","Check catalog configuration (warehouse, URI) points at the environment that actually contains the table","Refresh the Spark session/catalog if the table was recently created or recreated by another process","Catch Spark's NoSuchTableException (org.apache.spark.sql.catalyst.NoSuchTableException) around loadTable in programmatic use"],"exampleFix":"// before\nTable t = sparkCatalog.loadTable(Identifier.of(new String[]{\"db\"}, \"tabl\"));\n// after\nIdentifier ident = Identifier.of(new String[]{\"db\"}, \"table\");\nif (catalogOps.tableExists(ident)) {\n  Table t = sparkCatalog.loadTable(ident);\n}","handlingStrategy":"try-catch","validationCode":"if (!catalog.tableExists(ident)) {\n  throw new IllegalStateException(\"Table \" + ident + \" does not exist in \" + catalogName);\n}","typeGuard":null,"tryCatchPattern":"try { table = sparkCatalog.loadTable(ident); } catch (NoSuchTableException e) { /* check identifier spelling/casing and catalog config */ }","preventionTips":["Call tableExists before loadTable in programmatic paths","Verify warehouse/URI config points at the correct environment","Refresh the session after external drop/recreate operations"],"tags":["spark","catalog","table-not-found","identifier"],"backgroundTag":"resource-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"}