apache/iceberg · error · UnsupportedOperationException
does not support purging tables
Error message
${CLASS_NAME} does not support purging tables What it means
SparkRewriteTableCatalog supports only staged table creation for rewrite procedures; purging (dropping plus deleting all data/metadata files) is a destructive DDL operation it does not implement, so purgeTable always throws UnsupportedOperationException naming the class.
Solutions
- Point the table's catalog at SparkCatalog or the real underlying Iceberg catalog (Hive/REST/Hadoop) before purging
- Use the staging/rewrite catalog only for its supported stageCreate/stageReplace flows
- Handle UnsupportedOperationException explicitly and delegate purge to the correct catalog
Example fix
// before
catalog(asTableCatalog("rewrite")).purgeTable(ident);
// after
catalog(asTableCatalog("prod")).purgeTable(ident); Defensive patterns
Strategy: try-catch
Validate before calling
if (catalog instanceof SparkRewriteTableCatalog) {
// purge must go to the real catalog
return;
} Type guard
boolean supportsPurge(Catalog c) { return !(c instanceof SparkRewriteTableCatalog); } Try / catch
try {
catalog.purgeTable(ident);
} catch (UnsupportedOperationException e) {
prodCatalog.purgeTable(ident);
} Prevention
- Keep purge/retention jobs pointed at the production catalog
- Do not expose the rewrite catalog in user-facing session configs
- Test cleanup pipelines with the catalog implementations used in production
When it happens
Trigger: Calling purgeTable(ident) directly, or executing SQL that maps to purge (e.g. DROP TABLE PURGE in Spark when the target resolves to this catalog).
Common situations: Retention/cleanup jobs issuing DROP TABLE ... PURGE against a misconfigured catalog; testing code against the rewrite catalog instead of the production catalog.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Altering a view is not supported by catalog:
- Altering a view is not supported by catalog
- Altering a view is not supported by catalog
- Altering a view is not supported by catalog
- Cannot apply unknown table change
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/56b88607a8d56b28.
Report an issue: GitHub.
Appendix: source
Thrown at spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/SparkRewriteTableCatalog.java:95
public SparkTable createTable(
Identifier ident, StructType schema, Transform[] partitions, Map<String, String> properties)
throws TableAlreadyExistsException {
throw new UnsupportedOperationException(CLASS_NAME + " does not support creating tables");
}
@Override
public SparkTable alterTable(Identifier ident, TableChange... changes) {
throw new UnsupportedOperationException(CLASS_NAME + " does not support altering tables");
}
@Override
public boolean dropTable(Identifier ident) {
throw new UnsupportedOperationException(CLASS_NAME + " does not support dropping tables");
}
@Override
public boolean purgeTable(Identifier ident) throws UnsupportedOperationException {
throw new UnsupportedOperationException(CLASS_NAME + " does not support purging tables");
}
@Override
public void renameTable(Identifier oldIdent, Identifier newIdent) {
throw new UnsupportedOperationException(CLASS_NAME + " does not support renaming tables");
}
@Override
public void initialize(String catalogName, CaseInsensitiveStringMap options) {
this.name = catalogName;
}
@Override
public String name() {
return name;
}
private void validateNoNamespace(Identifier ident) {View on GitHub (pinned to 86d9c8fc54)