{"record":{"id":"e19e2ba5f1c0f4c4","repo":"apache/iceberg","slug":"nosuchtableexception-from-e19e2b","errorCode":null,"errorMessage":"NoSuchTableException: <from>","messagePattern":"NoSuchTableException: <from>","errorType":"exception","errorClass":"org.apache.spark.sql.catalyst.analysis.NoSuchTableException","httpStatus":null,"severity":"error","filePath":"spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java","lineNumber":381,"sourceCode":"  }\n\n  private boolean catalogDropTable(Identifier ident) {\n    if (isPathIdentifier(ident)) {\n      return tables.dropTable(((PathIdentifier) ident).location(), false /* don't purge data */);\n    } else {\n      return icebergCatalog.dropTable(buildIdentifier(ident), false /* don't purge data */);\n    }\n  }\n\n  @Override\n  public void renameTable(Identifier from, Identifier to)\n      throws NoSuchTableException, TableAlreadyExistsException {\n    try {\n      checkNotPathIdentifier(from, \"renameTable\");\n      checkNotPathIdentifier(to, \"renameTable\");\n      icebergCatalog.renameTable(buildIdentifier(from), buildIdentifier(to));\n    } catch (org.apache.iceberg.exceptions.NoSuchTableException e) {\n      throw new NoSuchTableException(from);\n    } catch (AlreadyExistsException e) {\n      throw new TableAlreadyExistsException(to);\n    }\n  }\n\n  @Override\n  public void invalidateTable(Identifier ident) {\n    if (!isPathIdentifier(ident)) {\n      icebergCatalog.invalidateTable(buildIdentifier(ident));\n    }\n  }\n\n  @Override\n  public Identifier[] listTables(String[] namespace) {\n    return icebergCatalog.listTables(Namespace.of(namespace)).stream()\n        .map(ident -> Identifier.of(ident.namespace().levels(), ident.name()))\n        .toArray(Identifier[]::new);\n  }","sourceCodeStart":363,"sourceCodeEnd":399,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java#L363-L399","documentation":"renameTable delegates to the Iceberg catalog; when the source table cannot be found, the Iceberg NoSuchTableException is translated into Spark's NoSuchTableException carrying the source identifier. The rename never starts because the 'from' table does not exist in this catalog.","triggerScenarios":"ALTER TABLE ... RENAME TO where the source identifier is misspelled, was dropped, or resolves to a different catalog/namespace than expected.","commonSituations":"Rename across sessions/catalogs; case-sensitive identifier mismatch; concurrent drop by another job before the rename.","solutions":["Confirm the source table exists via SHOW TABLES in the same catalog","Check that the statement runs against the correct spark catalog plugin","Correct the source identifier spelling/casing","Guard with an existence check before renaming"],"exampleFix":"// before\nspark.sql(\"ALTER TABLE db.orders RENAME TO db.orders_archive\") // table absent\n// after\nif (spark.catalog().tableExists(\"db.orders\")) { spark.sql(\"ALTER TABLE db.orders RENAME TO db.orders_archive\"); }","handlingStrategy":"try-catch","validationCode":"if (!spark.catalog().tableExists(fromIdent)) { return; }","typeGuard":null,"tryCatchPattern":"try { spark.sql(\"ALTER TABLE db.t RENAME TO db.t2\"); } catch (NoSuchTableException e) { /* source missing: handle */ }","preventionTips":["Check source existence before rename","Run renames in the same catalog/namespace where the table was created","Make pipelines idempotent for dropped sources"],"tags":["spark","rename","table-not-found"],"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-23T08:17:48.524Z"}