{"record":{"id":"8c7a229ae11291bd","repo":"apache/iceberg","slug":"sparkcachedtablecatalog-does-not-support-listing-t","errorCode":null,"errorMessage":"SparkCachedTableCatalog does not support listing tables","messagePattern":"SparkCachedTableCatalog does not support listing tables","errorType":"exception","errorClass":"java.lang.UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/SparkCachedTableCatalog.java","lineNumber":62,"sourceCode":"\n/** An internal table catalog that is capable of loading tables from a cache. */\npublic class SparkCachedTableCatalog implements TableCatalog, SupportsFunctions {\n\n  private static final String CLASS_NAME = SparkCachedTableCatalog.class.getName();\n  private static final Splitter COMMA = Splitter.on(\",\");\n  private static final Pattern AT_TIMESTAMP = Pattern.compile(\"at_timestamp_(\\\\d+)\");\n  private static final Pattern SNAPSHOT_ID = Pattern.compile(\"snapshot_id_(\\\\d+)\");\n  private static final Pattern BRANCH = Pattern.compile(\"branch_(.*)\");\n  private static final Pattern TAG = Pattern.compile(\"tag_(.*)\");\n  private static final String REWRITE = \"rewrite\";\n\n  private static final SparkTableCache TABLE_CACHE = SparkTableCache.get();\n\n  private String name = null;\n\n  @Override\n  public Identifier[] listTables(String[] namespace) {\n    throw new UnsupportedOperationException(CLASS_NAME + \" does not support listing tables\");\n  }\n\n  @Override\n  public SparkTable loadTable(Identifier ident) throws NoSuchTableException {\n    return load(ident);\n  }\n\n  @Override\n  public SparkTable loadTable(Identifier ident, String version) throws NoSuchTableException {\n    SparkTable table = load(ident);\n    Preconditions.checkArgument(\n        table.snapshotId() == null, \"Cannot time travel based on both table identifier and AS OF\");\n    return table.copyWithSnapshotId(Long.parseLong(version));\n  }\n\n  @Override\n  public SparkTable loadTable(Identifier ident, long timestampMicros) throws NoSuchTableException {\n    SparkTable table = load(ident);","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/SparkCachedTableCatalog.java#L44-L80","documentation":"Capability guard in SparkCachedTableCatalog.listTables: this internal catalog only resolves cached table loads (e.g. snapshot/branch/tag time-trap identifiers) and has no table listing. The message names the class; the failure is structural, not data-dependent.","triggerScenarios":"Calling SHOW TABLES / listTables against a namespace in the SparkCachedTableCatalog (the catalog used for cached tables, named like spark_catalog_cached or accessed through cached table identifiers).","commonSituations":"Exploring catalogs in a SQL client and listing all namespaces/tables; tools that enumerate catalog contents encounter this read-only cache catalog.","solutions":["List tables in the underlying real catalog (spark_catalog or the Iceberg catalog) instead","Avoid invoking listTables on the cached-table catalog; cache lookups go through loadTable only","Guard catalog-listing tooling to skip non-listable catalogs"],"exampleFix":"// before\ncatalogManager.catalog(\"spark_catalog_cached\").asTableCatalog().listTables(ns);\n// after\nTableCatalog real = catalogManager.catalog(\"spark_catalog\").asTableCatalog();\nIdentifier[] tables = real.listTables(ns);","handlingStrategy":"try-catch","validationCode":"if (catalog instanceof SparkCachedTableCatalog) { /* skip listing, use real catalog */ }","typeGuard":"boolean isListable(Catalog catalog) { return !(catalog instanceof SparkCachedTableCatalog); }","tryCatchPattern":"try { return catalog.listTables(namespace); } catch (UnsupportedOperationException e) { return realCatalog.listTables(namespace); }","preventionTips":["Skip cache-backed catalogs when enumerating catalog contents","List from the underlying catalog instead","Document cached-table catalogs as non-listable in tooling"],"tags":["spark","catalog","cache"],"backgroundTag":"operation-not-supported","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"}