apache/iceberg · error · NoSuchTableException
Cannot find source table
Error message
Cannot find source table '%s'
What it means
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.
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
Example fix
// before
SparkActions.get(spark).snapshotTable()
.identify("orders") // ambiguous / missing namespace
...
// after
SparkActions.get(spark).snapshotTable()
.identify("spark_catalog.db.orders")
... Defensive patterns
Strategy: try-catch
Validate before calling
if (!spark.sessionState().catalogManager().catalog(sourceCatalogName).asTableCatalog().tableExists(ident)) { throw new IllegalStateException("Source table missing: " + ident); } Try / catch
try { action.execute(); } catch (NoSuchTableException e) { LOG.error("Cannot find source table {}", e.getMessage()); throw e; } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Couldn't load table ' ' in catalog
- Couldn't load table ' ' in catalog
- NoSuchTableException(from)
- NoSuchTableException(ident)
- NoSuchTableException(ident)
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/fac9f4231559e0ae.
Report an issue: GitHub.
Appendix: source
Thrown at spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/actions/BaseTableCreationSparkAction.java:81
private final String sourceTableLocation;
private final TableCatalog sourceCatalog;
private final Identifier sourceTableIdent;
// Optional Parameters for destination
private final Map<String, String> additionalProperties = Maps.newHashMap();
BaseTableCreationSparkAction(
SparkSession spark, CatalogPlugin sourceCatalog, Identifier sourceTableIdent) {
super(spark);
this.sourceCatalog = checkSourceCatalog(sourceCatalog);
this.sourceTableIdent = sourceTableIdent;
try {
this.sourceTable = (V1Table) this.sourceCatalog.loadTable(sourceTableIdent);
this.sourceCatalogTable = sourceTable.v1Table();
} catch (org.apache.spark.sql.catalyst.analysis.NoSuchTableException e) {
throw new NoSuchTableException("Cannot find source table '%s'", sourceTableIdent);
} catch (ClassCastException e) {
throw new IllegalArgumentException(
String.format("Cannot use non-v1 table '%s' as a source", sourceTableIdent), e);
}
validateSourceTable();
this.sourceTableLocation =
CatalogUtils.URIToString(sourceCatalogTable.storage().locationUri().get());
}
protected abstract TableCatalog checkSourceCatalog(CatalogPlugin catalog);
protected abstract StagingTableCatalog destCatalog();
protected abstract Identifier destTableIdent();
protected abstract Map<String, String> destTableProps();
View on GitHub (pinned to 86d9c8fc54)