apache/iceberg · error · org.apache.spark.sql.catalyst.analysis.NoSuchTableException

No such table: %s

Error message

No such table: %s

What it means

SparkCatalog.loadTable(ident) delegates to load(ident); when the underlying Iceberg catalog throws org.apache.iceberg.exceptions.NoSuchTableException, it is translated into Spark's NoSuchTableException carrying 'No such table: <ident>'. This is the standard 'table does not exist in this catalog' signal.

Source

Thrown at spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java:179

    return CatalogUtil.buildIcebergCatalog(name, optionsMap, conf);
  }

  /**
   * Build an Iceberg {@link TableIdentifier} for the given Spark identifier.
   *
   * @param identifier Spark's identifier
   * @return an Iceberg identifier
   */
  protected TableIdentifier buildIdentifier(Identifier identifier) {
    return Spark3Util.identifierToTableIdentifier(identifier);
  }

  @Override
  public Table loadTable(Identifier ident) throws NoSuchTableException {
    try {
      return load(ident);
    } catch (org.apache.iceberg.exceptions.NoSuchTableException e) {
      throw new NoSuchTableException(ident);
    }
  }

  @Override
  public Table loadTable(Identifier ident, String version) throws NoSuchTableException {
    Table table = loadTable(ident);

    if (table instanceof SparkTable) {
      SparkTable sparkTable = (SparkTable) table;

      Preconditions.checkArgument(
          sparkTable.snapshotId() == null && sparkTable.branch() == null,
          "Cannot do time-travel based on both table identifier and AS OF");

      try {
        return sparkTable.copyWithSnapshotId(Long.parseLong(version));
      } catch (NumberFormatException e) {
        SnapshotRef ref = sparkTable.table().refs().get(version);

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Verify the table exists: SHOW TABLES IN <catalog>.<namespace> or catalog.tableExists(ident).
  2. Check the catalog configuration (spark.sql.catalog.<name>...) points at the intended warehouse/URI.
  3. Correct identifier spelling and namespace qualification in the query or Identifier.of(...) call.
  4. If the table was recently created, refresh metadata (spark.catalog.refreshTable / REFRESH TABLE) or recreate the session cache.

Example fix

// before
Table t = sparkCatalog.loadTable(Identifier.of(new String[]{"db"}, "tbl")); // NoSuchTableException

// after
Identifier id = Identifier.of(new String[]{"db"}, "tbl");
if (sparkCatalog.tableExists(id)) {
  Table t = sparkCatalog.loadTable(id);
}
Defensive patterns

Strategy: try-catch

Validate before calling

Identifier ident = Identifier.of(namespace, name);
boolean exists = sparkCatalog.tableExists(ident);
if (!exists) {
  throw new IllegalStateException("Table " + ident + " not found in catalog; check catalog config and spelling");
}

Type guard

boolean tableResolvable = sparkCatalog instanceof SparkCatalog && sparkCatalog.tableExists(ident);

Try / catch

try {
  Table t = sparkCatalog.loadTable(ident);
} catch (org.apache.spark.sql.catalyst.analysis.NoSuchTableException e) {
  // verify SHOW TABLES IN catalog.namespace, catalog options, and identifier casing
}

Prevention

When it happens

Trigger: loadTable(ident) on SparkCatalog where the identifier is not present in the configured catalog (typo, wrong catalog name, table dropped, or namespace omitted).

Common situations: Wrong catalog option in spark.sql.catalog.<name> pointing at a different warehouse; reading a table that another job dropped; case-sensitivity issues (spark.sql.caseSensitive off with mixed-case names); failing over to a catalog where the table was never created.

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


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/4cee800042cda945. Report an issue: GitHub.