{"record":{"id":"8ef39e7179177693","repo":"apache/iceberg","slug":"table-not-found-from","errorCode":null,"errorMessage":"Table not found: ${from}","messagePattern":"Table not found: (.+?)","errorType":"exception","errorClass":"NoSuchTableException","httpStatus":null,"severity":"error","filePath":"spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java","lineNumber":409,"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":391,"sourceCodeEnd":427,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java#L391-L427","documentation":"Thrown by SparkCatalog.renameTable when the underlying Iceberg catalog reports that the source table does not exist. Spark translates the Iceberg NoSuchTableException into Spark's org.apache.spark.sql.catalyst.analysis.NoSuchTableException carrying the original identifier. It means the rename's source identifier resolved to nothing in the catalog.","triggerScenarios":"Calling ALTER TABLE ... RENAME TO or SparkCatalog.renameTable(from, to) where 'from' is not a table in the catalog: the table was dropped, the name is misspelled or wrongly qualified, or a path identifier (a table loaded by 'spark_catalog.<path>') is passed since path identifiers are rejected.","commonSituations":"Renaming a table in a different namespace than assumed (missing qualifier), using a session catalog that points at a different warehouse than where the table lives, typos in table names, or attempting to rename a path-based table.","solutions":["Verify the source table exists with 'SHOW TABLES IN <catalog>.<namespace>' or catalog.tableExists before renaming","Check the identifier is fully qualified (namespace + name) and not a path identifier (starting with an absolute location)","Confirm you are connected to the same catalog/warehouse that contains the table (check spark.sql.catalog.<name>.warehouse / type)","Recreate or re-register the table if it was dropped"],"exampleFix":"// before\nspark.sql(\"ALTER TABLE prod.events RENAME TO prod.events_archive\")\n// after\nif (!spark.catalog().tableExists(\"prod\", \"events\")) {\n  throw new IllegalStateException(\"Source table prod.events does not exist\");\n}\nspark.sql(\"ALTER TABLE prod.events RENAME TO prod.events_archive\")","handlingStrategy":"validation","validationCode":"if (!spark.catalog().tableExists(fromNamespace, fromName)) {\n  throw new IllegalArgumentException(\"Source table does not exist: \" + from);\n}\nif (from instanceof PathIdentifier || to instanceof PathIdentifier) {\n  throw new IllegalArgumentException(\"renameTable does not support path identifiers\");\n}","typeGuard":"boolean isRenameable(TableCatalog catalog, Identifier from, Identifier to) {\n  return catalog.tableExists(from) && !catalog.tableExists(to);\n}","tryCatchPattern":"try {\n  catalog.renameTable(from, to);\n} catch (org.apache.spark.sql.catalyst.analysis.NoSuchTableException e) {\n  log.error(\"Rename failed, source table missing: {}\", from, e);\n  throw new IllegalStateException(\"Cannot rename missing table \" + from, e);\n}","preventionTips":["Always qualify table names with catalog and namespace","Check tableExists(from) before renaming","Avoid path identifiers (tables loaded by location) for renames","Pin catalog warehouse config so all jobs point at the same metastore"],"tags":["spark","catalog","rename-table","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"}