apache/iceberg · error · NoSuchTableException

Cannot find source table %s

Error message

Cannot find source table %s

What it means

MigrateTable renames the source Spark table to a backup identifier before creating the new Iceberg table. If the rename fails with catalyst NoSuchTableException — the source table cannot be found in the destination catalog — the action throws Iceberg's NoSuchTableException with this message.

Source

Thrown at spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/actions/MigrateTableSparkAction.java:239

  @Override
  protected TableCatalog checkSourceCatalog(CatalogPlugin catalog) {
    // currently the import code relies on being able to look up the table in the session catalog
    Preconditions.checkArgument(
        catalog instanceof SparkSessionCatalog,
        "Cannot migrate a table from a non-Iceberg Spark Session Catalog. Found %s of class %s as the source catalog.",
        catalog.name(),
        catalog.getClass().getName());

    return (TableCatalog) catalog;
  }

  private void renameAndBackupSourceTable() {
    try {
      LOG.info("Renaming {} as {} for backup", sourceTableIdent(), backupIdent);
      destCatalog().renameTable(sourceTableIdent(), backupIdent);

    } catch (org.apache.spark.sql.catalyst.analysis.NoSuchTableException e) {
      throw new NoSuchTableException("Cannot find source table %s", sourceTableIdent());

    } catch (org.apache.spark.sql.catalyst.analysis.TableAlreadyExistsException e) {
      throw new AlreadyExistsException(
          "Cannot rename %s as %s for backup. The backup table already exists.",
          sourceTableIdent(), backupIdent);
    }
  }

  private void restoreSourceTable() {
    try {
      LOG.info("Restoring {} from {}", sourceTableIdent(), backupIdent);
      destCatalog().renameTable(backupIdent, sourceTableIdent());

    } catch (org.apache.spark.sql.catalyst.analysis.NoSuchTableException e) {
      LOG.error(
          "Cannot restore the original table, the backup table {} cannot be found", backupIdent, e);

    } catch (org.apache.spark.sql.catalyst.analysis.TableAlreadyExistsException e) {

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Verify the source table exists with DESCRIBE TABLE / SHOW TABLES in the target catalog
  2. Check the table identifier (catalog, namespace, table) and catalog configuration
  3. Ensure the source is a real table (not a temp view) that the catalog can rename

Example fix

// before
actions.migrateTable("db.source"); // table actually in 'staging.db.source'
// after
actions.migrateTable("staging.db.source");
Defensive patterns

Strategy: validation

Validate before calling

if (!spark.catalog().tableExists(sourceIdent)) { throw new IllegalArgumentException("Source table missing: " + sourceIdent); }

Try / catch

try { action.execute(); } catch (NoSuchTableException e) { /* verify/fix source identifier before retry */ }

Prevention

When it happens

Trigger: Calling MigrateTableSparkAction.doExecute where sourceTableIdent() does not resolve in destCatalog at the rename step; e.g. the table was dropped or the identifier refers to a view/temp view that the catalog cannot rename.

Common situations: Typo in table identifier; source table is a Spark temp view or a non-Iceberg view not renameable by the catalog; concurrent drop of the source table; wrong catalog specified for the source identifier.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/ec429239ffdc961e. Report an issue: GitHub.