{"record":{"id":"ebfe1a6e40d3d976","repo":"apache/iceberg","slug":"class-name-does-not-support-dropping-tables","errorCode":null,"errorMessage":"${CLASS_NAME} does not support dropping tables","messagePattern":"(.+?) does not support dropping tables","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/SparkRewriteTableCatalog.java","lineNumber":90,"sourceCode":"  public void invalidateTable(Identifier ident) {\n    throw new UnsupportedOperationException(CLASS_NAME + \" does not support table invalidation\");\n  }\n\n  @Override\n  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","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/SparkRewriteTableCatalog.java#L72-L108","documentation":"SparkRewriteTableCatalog is a build-and-commit catalog used only for staged rewrite procedures (e.g. REWRITE DATA FILES). It intentionally implements table mutation methods as unsupported: dropping a table through it would bypass the rewrite protocol, so any dropTable call throws UnsupportedOperationException with the catalog class name.","triggerScenarios":"Calling dropTable(ident) on a catalog registered as org.apache.iceberg.spark.SparkRewriteTableCatalog, e.g. running DROP TABLE against a Spark session whose session/catalog config points at the rewrite catalog, or invoking SparkCatalog/Spark3Util paths that delegate mutation to it.","commonSituations":"Misconfigured spark.sql.catalog.<name>.implementation pointing at SparkRewriteTableCatalog instead of SparkCatalog; SQL scripts that assume all Iceberg catalogs support DDL; automated table lifecycle jobs hitting the wrong catalog.","solutions":["Use SparkCatalog (org.apache.iceberg.spark.SparkCatalog) or SparkSessionCatalog as the catalog implementation for DDL operations","Register the rewrite catalog only for procedure-style rewrite usage, not as the session default catalog","Catch UnsupportedOperationException and route DDL to the real Hive/REST/Hadoop catalog"],"exampleFix":"// before\nspark.sql.catalog.ice = org.apache.iceberg.spark.SparkRewriteTableCatalog\n// after\nspark.sql.catalog.ice = org.apache.iceberg.spark.SparkCatalog","handlingStrategy":"try-catch","validationCode":"// verify the catalog supports mutation before DDL\nif (catalog instanceof SparkRewriteTableCatalog) {\n  throw new IllegalStateException(\"Route DDL to a full catalog, not the rewrite catalog\");\n}","typeGuard":"boolean supportsDdl(CatalogPlugin c) {\n  return c instanceof SparkCatalog || c instanceof SparkSessionCatalog;\n}","tryCatchPattern":"try {\n  catalog.dropTable(ident);\n} catch (UnsupportedOperationException e) {\n  // fall back to the production catalog\n  prodCatalog.dropTable(ident);\n}","preventionTips":["Register SparkRewriteTableCatalog only for rewrite procedure sessions","Default session catalogs to SparkCatalog/SparkSessionCatalog","Audit spark.sql.catalog.* implementation configs in deployment templates"],"tags":["spark","unsupported-operation","catalog"],"backgroundTag":"unsupported-operation","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}