{"record":{"id":"e475046c403a4991","repo":"apache/iceberg","slug":"cannot-find-source-table-s-e47504","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/BaseTableCreationSparkAction.java","lineNumber":80,"sourceCode":"  private final String sourceTableLocation;\n  private final TableCatalog sourceCatalog;\n  private final Identifier sourceTableIdent;\n\n  // Optional Parameters for destination\n  private final Map<String, String> additionalProperties = Maps.newHashMap();\n\n  BaseTableCreationSparkAction(\n      SparkSession spark, CatalogPlugin sourceCatalog, Identifier sourceTableIdent) {\n    super(spark);\n\n    this.sourceCatalog = checkSourceCatalog(sourceCatalog);\n    this.sourceTableIdent = sourceTableIdent;\n\n    try {\n      this.sourceTable = (V1Table) this.sourceCatalog.loadTable(sourceTableIdent);\n      this.sourceCatalogTable = sourceTable.v1Table();\n    } catch (org.apache.spark.sql.catalyst.analysis.NoSuchTableException e) {\n      throw new NoSuchTableException(\"Cannot find source table '%s'\", sourceTableIdent);\n    } catch (ClassCastException e) {\n      throw new IllegalArgumentException(\n          String.format(\"Cannot use non-v1 table '%s' as a source\", sourceTableIdent), e);\n    }\n    validateSourceTable();\n\n    this.sourceTableLocation =\n        CatalogUtils.URIToString(sourceCatalogTable.storage().locationUri().get());\n  }\n\n  protected abstract TableCatalog checkSourceCatalog(CatalogPlugin catalog);\n\n  protected abstract StagingTableCatalog destCatalog();\n\n  protected abstract Identifier destTableIdent();\n\n  protected abstract Map<String, String> destTableProps();\n","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/actions/BaseTableCreationSparkAction.java#L62-L98","documentation":"BaseTableCreationSparkAction's constructor loads the source table from the given Spark catalog; if Spark reports NoSuchTableException, it is rethrown as Iceberg's NoSuchTableException with the identifier. Create-table-like actions (snapshot/clone/migrate) require an existing source table.","triggerScenarios":"Running snapshot / migrate / create-like Spark actions with a source identifier that doesn't exist in the source catalog — typo, wrong namespace, wrong catalog, or table dropped before the action.","commonSituations":"Migrating a Hive/Spark table whose name was mistyped; pointing at a catalog where the table was never created; case-sensitivity mismatches in identifiers.","solutions":["Verify the source table exists: SHOW TABLES in the namespace or spark.catalog.tableExists","Check the catalog and namespace parts of the identifier are correct","Confirm you are connected to the intended catalog/metastore"],"exampleFix":"// before\nCALL catalog.system.snapshot('prod.db.orders', 'db.orders_backup')\n// after\nCALL catalog.system.snapshot('prod.db.orders', 'db.orders_src') // ensure source ident resolves","handlingStrategy":"try-catch","validationCode":"if (!spark.sessionState().catalogManager().catalog(sourceCatalogName).loadTable(ident) ...) // or spark.catalog.tableExists(db, table)","typeGuard":"boolean sourceExists(SparkSession spark, String db, String tbl) { return spark.catalog().tableExists(db, tbl); }","tryCatchPattern":"try { callAction(...); } catch (NoSuchTableException e) { LOG.error(\"Source table {} missing\", sourceIdent, e); throw e; }","preventionTips":["Validate source identifiers with SHOW TABLES before actions","Use fully qualified catalog.namespace.table identifiers","Watch for case-sensitivity in catalog identifiers"],"tags":["spark","table-not-found","actions"],"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"}