apache/iceberg · error · UnsupportedOperationException

does not support listing tables

Error message

${CLASS_NAME} does not support listing tables

What it means

SparkRewriteTableCatalog is a minimal catalog plugin used only to service the rewrite-table procedure; it has no real table store behind it, so listTables always throws UnsupportedOperationException. It deliberately implements none of the general catalog management operations.

Solutions

  1. Use a real Iceberg catalog implementation (HiveCatalog, HadoopCatalog, RESTCatalog) for general table operations
  2. Ensure spark.sql.catalog.<name>.catalog-impl is not set to SparkRewriteTableCatalog
  3. Invoke the rewrite_data_files/rewrite_manifests procedures rather than treating the rewrite catalog as a normal catalog

Example fix

// before
spark.conf.set("spark.sql.catalog.prod.catalog-impl", "org.apache.iceberg.spark.SparkRewriteTableCatalog")
// after
spark.conf.set("spark.sql.catalog.prod.catalog-impl", "org.apache.iceberg.spark.SparkCatalog")
Defensive patterns

Strategy: validation

Validate before calling

val impl = spark.conf.get("spark.sql.catalog.prod.catalog-impl", "org.apache.iceberg.spark.SparkCatalog")
require(impl != "org.apache.iceberg.spark.SparkRewriteTableCatalog", "prod must use a real catalog")

Try / catch

try {
  catalog.listTables(namespace)
} catch {
  case _: UnsupportedOperationException => useRealCatalogInstead()
}

Prevention

When it happens

Trigger: Calling listTables(namespace) on a catalog instance of class SparkRewriteTableCatalog, e.g. via SHOW TABLES against a catalog registered as that class.

Common situations: Misconfiguring spark.sql.catalog.<name>.catalog-impl to the rewrite catalog instead of a real Iceberg catalog; programmatic calls on a rewrite-procedure catalog handle.

Related errors


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

Appendix: source

Thrown at spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/SparkRewriteTableCatalog.java:44

import org.apache.spark.sql.catalyst.analysis.NoSuchTableException;
import org.apache.spark.sql.catalyst.analysis.TableAlreadyExistsException;
import org.apache.spark.sql.connector.catalog.Identifier;
import org.apache.spark.sql.connector.catalog.TableCatalog;
import org.apache.spark.sql.connector.catalog.TableChange;
import org.apache.spark.sql.connector.expressions.Transform;
import org.apache.spark.sql.types.StructType;
import org.apache.spark.sql.util.CaseInsensitiveStringMap;

public class SparkRewriteTableCatalog implements TableCatalog, SupportsFunctions {

  private static final String CLASS_NAME = SparkRewriteTableCatalog.class.getName();
  private static final SparkTableCache TABLE_CACHE = SparkTableCache.get();

  private String name = null;

  @Override
  public Identifier[] listTables(String[] namespace) {
    throw new UnsupportedOperationException(CLASS_NAME + " does not support listing tables");
  }

  @Override
  public SparkRewriteTable loadTable(Identifier ident) throws NoSuchTableException {
    validateNoNamespace(ident);

    String groupId = ident.name();
    Table table = TABLE_CACHE.get(groupId);

    if (table == null) {
      throw new NoSuchTableException(ident);
    }

    return new SparkRewriteTable(table, groupId);
  }

  @Override
  public SparkTable loadTable(Identifier ident, String version) throws NoSuchTableException {

View on GitHub (pinned to 86d9c8fc54)