{"record":{"id":"fac9f4231559e0ae","repo":"apache/iceberg","slug":"cannot-find-source-table-s-fac9f4","errorCode":null,"errorMessage":"Cannot find source table '%s'","messagePattern":"Cannot find source table '(.+?)'","errorType":"exception","errorClass":"NoSuchTableException","httpStatus":null,"severity":"error","filePath":"spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/actions/BaseTableCreationSparkAction.java","lineNumber":81,"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":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/actions/BaseTableCreationSparkAction.java#L63-L99","documentation":"BaseTableCreationSparkAction's constructor loads the source table from the given Spark catalog. If Spark throws NoSuchTableException, it is translated into Iceberg's NoSuchTableException 'Cannot find source table %s'. This guards snapshotting/cloning actions (e.g. SNAPSHOT, MIGRATE) against a nonexistent or unresolvable identifier.","triggerScenarios":"Running SNAPSHOT/MIGRATE table procedures with a sourceTableIdent that does not exist in the supplied catalog, a mistyped table name, wrong namespace, or a catalog/session where the table is not visible.","commonSituations":"Typos in fully-qualified table names; table dropped between planning and execution; using a session catalog without USE of the right namespace; temporary views passed where a real table is required.","solutions":["Verify the table exists: SHOW TABLES IN <catalog>.<namespace> or spark.catalog.tableExists","Pass a fully-qualified identifier including the correct catalog and namespace","Check you are connected to the intended catalog (session vs metastore vs REST)","Recreate or restore the table if it was dropped"],"exampleFix":"// before\nSparkActions.get(spark).snapshotTable()\n    .identify(\"orders\")  // ambiguous / missing namespace\n    ...\n// after\nSparkActions.get(spark).snapshotTable()\n    .identify(\"spark_catalog.db.orders\")\n    ...","handlingStrategy":"try-catch","validationCode":"if (!spark.sessionState().catalogManager().catalog(sourceCatalogName).asTableCatalog().tableExists(ident)) { throw new IllegalStateException(\"Source table missing: \" + ident); }","typeGuard":null,"tryCatchPattern":"try { action.execute(); } catch (NoSuchTableException e) { LOG.error(\"Cannot find source table {}\", e.getMessage()); throw e; }","preventionTips":["Always pass fully-qualified catalog.namespace.table identifiers","Confirm the table exists before snapshot/migrate operations","Ensure the correct catalog is active in the Spark session"],"tags":["spark","table-not-found","catalog"],"backgroundTag":"resource-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"}