{"record":{"id":"bf8999c11f539943","repo":"apache/iceberg","slug":"nosuchtableexception-from","errorCode":null,"errorMessage":"NoSuchTableException(from)","messagePattern":"NoSuchTableException\\(from\\)","errorType":"exception","errorClass":"NoSuchTableException","httpStatus":null,"severity":"error","filePath":"spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java","lineNumber":430,"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":412,"sourceCodeEnd":448,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java#L412-L448","documentation":"Spark's renameTable failed because the source table identifier could not be loaded by the underlying Iceberg catalog; the Iceberg NoSuchTableException was caught and rethrown as Spark's NoSuchTableException for the 'from' identifier. Renaming requires the source table to exist and be loadable at commit time.","triggerScenarios":"Calling ALTER TABLE ... RENAME TO (or catalog.renameTable(from, to)) where buildIdentifier(from) does not resolve to an existing Iceberg table; the source was dropped concurrently; the 'from' identifier is qualified with the wrong catalog or namespace.","commonSituations":"Scripting RENAME operations where an earlier cleanup step already dropped the table; Hive-metastore-backed catalogs where the Hive table exists but the Iceberg metadata location is gone; passing an unqualified name while the table lives in another namespace.","solutions":["Confirm the source table exists and is loadable via SELECT before renaming.","Use the fully-qualified source name (catalog.namespace.table) to avoid resolution against the wrong catalog.","Check for concurrent drops; coordinate rename with other jobs.","If the metastore entry exists but loading fails, repair or re-register the table metadata location."],"exampleFix":"// before\nspark.sql(\"ALTER TABLE mydb.orders RENAME TO mydb.orders_v2\") // NoSuchTableException: mydb.orders\n\n// after\nif (spark.catalog().tableExists(\"iceberg_catalog.mydb.orders\")) {\n  spark.sql(\"ALTER TABLE iceberg_catalog.mydb.orders RENAME TO iceberg_catalog.mydb.orders_v2\")\n} else {\n  // handle missing source explicitly\n}","handlingStrategy":"validation","validationCode":"if (!spark.catalog().tableExists(\"iceberg_catalog.mydb.orders\")) {\n  throw new IllegalStateException(\"Rename source table does not exist\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  catalog.renameTable(from, to);\n} catch (NoSuchTableException e) {\n  // source missing: report e.getMessage() with the resolved identifier\n}","preventionTips":["Verify the source exists immediately before rename","Use fully-qualified source identifiers","Avoid renaming tables managed by concurrent pipelines","Re-register missing metadata before renaming migrated tables"],"tags":["spark","catalog","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-14T16:17:12.679Z"}