{"record":{"id":"39b10b063e2b015b","repo":"apache/iceberg","slug":"sparkcachedtablecatalog-does-not-support-purging-t","errorCode":null,"errorMessage":"SparkCachedTableCatalog does not support purging tables","messagePattern":"SparkCachedTableCatalog does not support purging 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":113,"sourceCode":"  public SparkTable createTable(\n      Identifier ident, StructType schema, Transform[] partitions, Map<String, String> properties)\n      throws TableAlreadyExistsException {\n    throw new UnsupportedOperationException(CLASS_NAME + \" does not support creating tables\");\n  }\n\n  @Override\n  public SparkTable alterTable(Identifier ident, TableChange... changes) {\n    throw new UnsupportedOperationException(CLASS_NAME + \" does not support altering tables\");\n  }\n\n  @Override\n  public boolean dropTable(Identifier ident) {\n    throw new UnsupportedOperationException(CLASS_NAME + \" does not support dropping tables\");\n  }\n\n  @Override\n  public boolean purgeTable(Identifier ident) throws UnsupportedOperationException {\n    throw new UnsupportedOperationException(CLASS_NAME + \" does not support purging tables\");\n  }\n\n  @Override\n  public void renameTable(Identifier oldIdent, Identifier newIdent) {\n    throw new UnsupportedOperationException(CLASS_NAME + \" does not support renaming tables\");\n  }\n\n  @Override\n  public void initialize(String catalogName, CaseInsensitiveStringMap options) {\n    this.name = catalogName;\n  }\n\n  @Override\n  public String name() {\n    return name;\n  }\n\n  private SparkTable load(Identifier ident) throws NoSuchTableException {","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/SparkCachedTableCatalog.java#L95-L131","documentation":"SparkCachedTableCatalog.purgeTable() throws UnsupportedOperationException always. Purging deletes table data and metadata permanently; a cache-backed, read-only view of tables can never perform this, so the method is a hard stop.","triggerScenarios":"Calling SparkCachedTableCatalog.purgeTable(ident) directly, or running PURGE TABLE / DROP TABLE PURGE in Spark SQL where resolution lands on the cached catalog.","commonSituations":"Retention/cleanup jobs that purge expired tables but route through the cached catalog; users attempting to reclaim storage after a cached read session; generic tooling that calls purgeTable on any CatalogPlugin.","solutions":["Purge via the owning catalog: ExpireSnapshots on the real org.apache.iceberg.Table, or PURGE TABLE against the original catalog identifier.","Run the purge from a session where the table identifier resolves to SparkCatalog (not the cached catalog).","If data deletion is the goal, use table.io().deleteFile / deleteFiles through the underlying Table rather than the catalog API."],"exampleFix":"// before\ncachedCatalog.purgeTable(Identifier.of(new String[]{\"db\"}, \"t\"));\n\n// after\nTable table = catalogOps.loadTable(\"db.t\"); // real catalog\ntable.expireSnapshots().expireOlderThan(System.currentTimeMillis() - retentionMs).commit();","handlingStrategy":"validation","validationCode":"if (catalog instanceof SparkCachedTableCatalog) {\n  throw new IllegalArgumentException(\"purgeTable is not supported on SparkCachedTableCatalog; use ExpireSnapshots on the real table\");\n}","typeGuard":"boolean canPurge = !(catalog instanceof SparkCachedTableCatalog);","tryCatchPattern":"try {\n  catalog.purgeTable(ident);\n} catch (UnsupportedOperationException e) {\n  // purge via real catalog or table.expireSnapshots()\n}","preventionTips":["Implement data retention with ExpireSnapshots on the org.apache.iceberg.Table, not catalog purge APIs.","Audit purge callers to ensure they hold a reference to the owning catalog.","Document cached-catalog namespaces as read-only in team runbooks."],"tags":["spark","catalog","ddl","unsupported-operation","cached-table"],"backgroundTag":"unsupported-operation","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"}