{"record":{"id":"330e559929ca5c03","repo":"apache/iceberg","slug":"org-apache-iceberg-exceptions-nosuchtableexception","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/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/v4.0/spark/src/main/java/org/apache/iceberg/spark/SparkCachedTableCatalog.java#L124-L160","documentation":"SparkCachedTableCatalog.load throws NoSuchTableException when SparkTableCache.get(key) returns null — i.e. the requested table was never cached (or was evicted). Only identifiers whose first field matches a cache key can be loaded.","triggerScenarios":"Querying a table identifier bound to the cached catalog whose cache key is absent: wrong cache key in the identifier, cache never populated, or entry evicted between statements.","commonSituations":"Referencing a cached table after session restart or cache clear; typo in the cached identifier; another job evicting cache entries concurrently.","solutions":["Ensure the table was cached via SparkTableCache with the exact key used in the identifier","Reload the table into the cache from the real catalog before querying","Check the identifier format: first field must equal the cache key"],"exampleFix":"// before\nspark.table(\"cached_catalog.wrong_key\")\n// after\n// cache the table first, then use the exact key\nspark.table(\"cached_catalog.\" + correctCacheKey)","handlingStrategy":"try-catch","validationCode":"// ensure the cache holds the key before loading\nif (SparkTableCache.get().get(cacheKey) == null) {\n  // populate the cache from the real catalog first\n}","typeGuard":null,"tryCatchPattern":"try { return cachedCatalog.loadTable(ident); } catch (NoSuchTableException e) { /* re-cache from the real catalog or surface a clear message */ }","preventionTips":["Always populate SparkTableCache before referencing identifiers through this catalog","Use the exact cache key as the first identifier field","Account for cache eviction between long-running statements"],"tags":["spark","catalog","cache-miss","table-not-found"],"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"}