{"record":{"id":"1e2b764fe490dcb9","repo":"apache/iceberg","slug":"cannot-find-source-table-s","errorCode":null,"errorMessage":"Cannot find source table '%s'","messagePattern":"Cannot find source table '(.+?)'","errorType":"exception","errorClass":"NoSuchTableException","httpStatus":null,"severity":"error","filePath":"spark/v3.5/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/v3.5/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 reports NoSuchTableException, it is translated into Iceberg's NoSuchTableException 'Cannot find source table'. Thrown before any snapshot/clone action (e.g. snapshot, migrate, addFiles) starts.","triggerScenarios":"Calling SparkActions.snapshot(\"catalog\", \"ns.dest\", ...) or migrate with a source table identifier that does not exist in the source catalog.","commonSituations":"Typo in table or namespace name; wrong catalog name in a multi-catalog session; table dropped between planning and execution; case-sensitive identifier mismatch.","solutions":["Verify the identifier exists: SHOW TABLES IN catalog.namespace","Confirm the Spark session has the correct catalog configured (spark.sql.catalog.<name>)","Check for typos and exact case of namespace and table names"],"exampleFix":"// before\nSparkActions.get(spark).snapshot(\"prod\", \"sales.fact\", \"iceberg.ns.fact\").execute();\n// after — verify identifier first\nspark.sql(\"SHOW TABLES IN prod.sales\");\nSparkActions.get(spark).snapshot(\"prod\", \"sales.facts\", \"iceberg.ns.fact\").execute();","handlingStrategy":"validation","validationCode":"Dataset<Row> check = spark.sql(\"SHOW TABLES IN \" + catalog + \".\" + namespace);\nboolean exists = check.collectAsList().stream().anyMatch(r -> r.getString(1).equalsIgnoreCase(table));\nif (!exists) throw new IllegalArgumentException(\"Source table not found: \" + ident);","typeGuard":"boolean sourceExists(SparkSession spark, String catalog, String ns, String tbl) { return !spark.sql(String.format(\"SHOW TABLES IN %s.%s\", catalog, ns)).filter(\"tableName = '\" + tbl + \"'\").isEmpty(); }","tryCatchPattern":"try { action.execute(); } catch (NoSuchTableException e) { throw new IllegalArgumentException(\"Verify source identifier: \" + e.getMessage(), e); }","preventionTips":["Run SHOW TABLES / DESCRIBE on the source before invoking snapshot/migrate","Use fully qualified identifiers with the correct catalog name","Beware case sensitivity in identifier matching"],"tags":["spark","actions","table-resolution"],"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"}