{"record":{"id":"ec429239ffdc961e","repo":"apache/iceberg","slug":"cannot-find-source-table-s-ec4292","errorCode":null,"errorMessage":"Cannot find source table %s","messagePattern":"Cannot find source table (.+?)","errorType":"exception","errorClass":"NoSuchTableException","httpStatus":null,"severity":"error","filePath":"spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/actions/MigrateTableSparkAction.java","lineNumber":239,"sourceCode":"  @Override\n  protected TableCatalog checkSourceCatalog(CatalogPlugin catalog) {\n    // currently the import code relies on being able to look up the table in the session catalog\n    Preconditions.checkArgument(\n        catalog instanceof SparkSessionCatalog,\n        \"Cannot migrate a table from a non-Iceberg Spark Session Catalog. Found %s of class %s as the source catalog.\",\n        catalog.name(),\n        catalog.getClass().getName());\n\n    return (TableCatalog) catalog;\n  }\n\n  private void renameAndBackupSourceTable() {\n    try {\n      LOG.info(\"Renaming {} as {} for backup\", sourceTableIdent(), backupIdent);\n      destCatalog().renameTable(sourceTableIdent(), backupIdent);\n\n    } catch (org.apache.spark.sql.catalyst.analysis.NoSuchTableException e) {\n      throw new NoSuchTableException(\"Cannot find source table %s\", sourceTableIdent());\n\n    } catch (org.apache.spark.sql.catalyst.analysis.TableAlreadyExistsException e) {\n      throw new AlreadyExistsException(\n          \"Cannot rename %s as %s for backup. The backup table already exists.\",\n          sourceTableIdent(), backupIdent);\n    }\n  }\n\n  private void restoreSourceTable() {\n    try {\n      LOG.info(\"Restoring {} from {}\", sourceTableIdent(), backupIdent);\n      destCatalog().renameTable(backupIdent, sourceTableIdent());\n\n    } catch (org.apache.spark.sql.catalyst.analysis.NoSuchTableException e) {\n      LOG.error(\n          \"Cannot restore the original table, the backup table {} cannot be found\", backupIdent, e);\n\n    } catch (org.apache.spark.sql.catalyst.analysis.TableAlreadyExistsException e) {","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/actions/MigrateTableSparkAction.java#L221-L257","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the source table exists with DESCRIBE TABLE / SHOW TABLES in the target catalog","Check the table identifier (catalog, namespace, table) and catalog configuration","Ensure the source is a real table (not a temp view) that the catalog can rename"],"exampleFix":"// before\nactions.migrateTable(\"db.source\"); // table actually in 'staging.db.source'\n// after\nactions.migrateTable(\"staging.db.source\");","handlingStrategy":"validation","validationCode":"if (!spark.catalog().tableExists(sourceIdent)) { throw new IllegalArgumentException(\"Source table missing: \" + sourceIdent); }","typeGuard":null,"tryCatchPattern":"try { action.execute(); } catch (NoSuchTableException e) { /* verify/fix source identifier before retry */ }","preventionTips":["Verify the source identifier resolves in the target catalog before migrating","Avoid passing temp views or views as migrate sources","Guard against concurrent drops of the source table"],"tags":["spark","iceberg","table-not-found","migration"],"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"}