{"record":{"id":"9a114c8603ffec7b","repo":"apache/iceberg","slug":"table-not-found-ident-9a114c","errorCode":null,"errorMessage":"Table not found: ${ident}","messagePattern":"Table not found: (.+?)","errorType":"exception","errorClass":"NoSuchTableException","httpStatus":null,"severity":"error","filePath":"spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/SparkRewriteTableCatalog.java","lineNumber":53,"sourceCode":"  private static final String CLASS_NAME = SparkRewriteTableCatalog.class.getName();\n  private static final SparkTableCache TABLE_CACHE = SparkTableCache.get();\n\n  private String name = null;\n\n  @Override\n  public Identifier[] listTables(String[] namespace) {\n    throw new UnsupportedOperationException(CLASS_NAME + \" does not support listing tables\");\n  }\n\n  @Override\n  public SparkRewriteTable loadTable(Identifier ident) throws NoSuchTableException {\n    validateNoNamespace(ident);\n\n    String groupId = ident.name();\n    Table table = TABLE_CACHE.get(groupId);\n\n    if (table == null) {\n      throw new NoSuchTableException(ident);\n    }\n\n    return new SparkRewriteTable(table, groupId);\n  }\n\n  @Override\n  public SparkTable loadTable(Identifier ident, String version) throws NoSuchTableException {\n    throw new UnsupportedOperationException(CLASS_NAME + \" does not support time travel\");\n  }\n\n  @Override\n  public SparkTable loadTable(Identifier ident, long timestampMicros) throws NoSuchTableException {\n    throw new UnsupportedOperationException(CLASS_NAME + \" does not support time travel\");\n  }\n\n  @Override\n  public void invalidateTable(Identifier ident) {\n    throw new UnsupportedOperationException(CLASS_NAME + \" does not support table invalidation\");","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/SparkRewriteTableCatalog.java#L35-L71","documentation":"loadTable on SparkRewriteTableCatalog looks up the table only in the in-memory SparkTableCache keyed by the identifier name; when the groupId is absent from the cache it throws NoSuchTableException for the identifier. It never consults a real catalog.","triggerScenarios":"Calling SparkRewriteTableCatalog.loadTable(ident) with an identifier whose name is not a groupId currently registered in SparkTableCache — e.g. loading the table outside a rewrite procedure, after the cache entry expired, or with a wrong/renamed identifier.","commonSituations":"Invoking loadTable on the rewrite catalog from application code instead of through the rewrite procedure; stale cache entries evicted between procedure stages; identifier mismatch between the procedure call and the cached entry.","solutions":["Load the table through the proper catalog (SparkCatalog) rather than SparkRewriteTableCatalog.","Only use the rewrite catalog within the Spark rewrite procedures that populate the cache.","Verify the identifier name matches the groupId the rewrite procedure registered in SparkTableCache.","Re-run the rewrite procedure if its cache entry was evicted."],"exampleFix":"// before\nSparkRewriteTable t = (SparkRewriteTable) rewriteCatalog.loadTable(ident);\n// after\nSparkTable t = (SparkTable) sparkCatalog.loadTable(ident); // use the real catalog for direct loads","handlingStrategy":"try-catch","validationCode":"String groupId = ident.name();\nif (!sparkTableCache.contains(groupId)) {\n  throw new IllegalStateException(\"groupId not in SparkTableCache: \" + groupId);\n}","typeGuard":null,"tryCatchPattern":"try {\n  Table t = rewriteCatalog.loadTable(ident);\n} catch (NoSuchTableException e) {\n  Table t = realCatalog.loadTable(ident); // fall back to the authoritative catalog\n}","preventionTips":["Only load via the rewrite catalog inside Spark rewrite procedures that populate the cache.","Match identifier names exactly to the registered groupId.","Use the real catalog for direct table loads.","Re-run the procedure if cache entries were evicted."],"tags":["spark","rewrite","table-not-found","cache"],"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"}