{"record":{"id":"8792bd4c539aa946","repo":"apache/iceberg","slug":"no-such-table-s-8792bd","errorCode":null,"errorMessage":"No such table: %s","messagePattern":"No such table: (.+?)","errorType":"exception","errorClass":"org.apache.spark.sql.catalyst.analysis.NoSuchTableException","httpStatus":null,"severity":"error","filePath":"spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/SparkCachedTableCatalog.java","lineNumber":142,"sourceCode":"  }\n\n  @Override\n  public String name() {\n    return name;\n  }\n\n  private SparkTable load(Identifier ident) throws NoSuchTableException {\n    Preconditions.checkArgument(\n        ident.namespace().length == 0, CLASS_NAME + \" does not support namespaces\");\n\n    Pair<String, List<String>> parsedIdent = parseIdent(ident);\n    String key = parsedIdent.first();\n    TableLoadOptions options = parseLoadOptions(parsedIdent.second());\n\n    Table table = TABLE_CACHE.get(key);\n\n    if (table == null) {\n      throw new NoSuchTableException(ident);\n    }\n\n    if (options.isTableRewrite()) {\n      return new SparkTable(table, null, false, true);\n    }\n\n    if (options.snapshotId() != null) {\n      return new SparkTable(table, options.snapshotId(), false);\n    } else if (options.asOfTimestamp() != null) {\n      return new SparkTable(\n          table, SnapshotUtil.snapshotIdAsOfTime(table, options.asOfTimestamp()), false);\n    } else if (options.branch() != null) {\n      Snapshot branchSnapshot = table.snapshot(options.branch());\n      Preconditions.checkArgument(\n          branchSnapshot != null,\n          \"Cannot find snapshot associated with branch name: %s\",\n          options.branch());\n      return new SparkTable(table, branchSnapshot.snapshotId(), false);","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/SparkCachedTableCatalog.java#L124-L160","documentation":"SparkCachedTableCatalog.load() looks up the table key in TABLE_CACHE and throws NoSuchTableException when the key is absent. Unlike SparkCatalog, this catalog does not reach out to a backing catalog; it can only serve what has already been cached, so any cache miss surfaces as 'No such table'.","triggerScenarios":"loadTable(ident) / table(ident) with an identifier whose first part (key) was never registered in the cache; the cached entry was invalidated or the session that populated the cache was recreated; a typo'd namespace in the identifier.","commonSituations":"Querying a cached table from a new SparkSession without re-registering it; referencing the table after cache eviction; case-sensitivity/key-format mismatch between how the table was cached and how it is loaded.","solutions":["Load/refresh the table through the real catalog first so the entry is populated in TABLE_CACHE, then query via the cached catalog.","Verify the identifier exactly matches the key used at registration (namespace and table name).","Check whether tableExists(ident) returns true before loading to fail fast.","If the table is truly persistent, use SparkCatalog instead of SparkCachedTableCatalog."],"exampleFix":"// before\nSparkTable t = cachedCatalog.loadTable(Identifier.of(new String[]{\"db\"}, \"t\")); // cache miss\n\n// after\nif (cachedCatalog.tableExists(Identifier.of(new String[]{\"db\"}, \"t\"))) {\n  SparkTable t = cachedCatalog.loadTable(Identifier.of(new String[]{\"db\"}, \"t\"));\n} else {\n  spark.sql(\"SELECT * FROM spark_catalog.db.t\"); // populates cache via real catalog\n}","handlingStrategy":"try-catch","validationCode":"Identifier ident = Identifier.of(namespace, name);\nif (!cachedCatalog.tableExists(ident)) {\n  // refresh cache via real catalog before loading\n  spark.table(\"spark_catalog.\" + String.join(\".\", namespace) + \".\" + name);\n}","typeGuard":"boolean isCached = key != null && cachedCatalog.tableExists(Identifier.of(new String[]{key}, tableName));","tryCatchPattern":"try {\n  SparkTable t = cachedCatalog.loadTable(ident);\n} catch (org.apache.spark.sql.catalyst.analysis.NoSuchTableException e) {\n  // re-register through the real catalog, then retry once\n}","preventionTips":["Always populate TABLE_CACHE through the real catalog before querying the cached catalog.","Match identifiers exactly (namespace + table, casing) to the key used at registration.","Call tableExists before load to fail fast with a clearer message.","After session restarts or cache eviction, expect misses and re-register."],"tags":["spark","catalog","cache-miss","no-such-table","cached-table"],"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"}