{"record":{"id":"265c46887e0ab258","repo":"apache/iceberg","slug":"class-name-does-not-support-renaming-tables","errorCode":null,"errorMessage":"${CLASS_NAME} does not support renaming tables","messagePattern":"(.+?) does not support renaming tables","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/SparkRewriteTableCatalog.java","lineNumber":100,"sourceCode":"\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 void validateNoNamespace(Identifier ident) {\n    Preconditions.checkArgument(\n        ident.namespace().length == 0,\n        \"%s does not support namespaces, but got: %s\",\n        CLASS_NAME,\n        String.join(\".\", ident.namespace()));","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/SparkRewriteTableCatalog.java#L82-L118","documentation":"Renaming a table would invalidate the staged-rewrite contract of SparkRewriteTableCatalog, so renameTable unconditionally throws UnsupportedOperationException with the class name. This catalog exists solely to stage create/replace during rewrite procedures.","triggerScenarios":"Calling renameTable(oldIdent, newIdent) on this catalog, or running ALTER TABLE ... RENAME TO where Spark routes the command to the rewrite catalog implementation.","commonSituations":"Session catalog configured as SparkRewriteTableCatalog; migration scripts renaming tables across catalogs; frameworks performing generic DDL against every registered catalog.","solutions":["Execute the rename against a full catalog implementation such as SparkCatalog backed by Hive/REST/Hadoop","Drop and recreate the table with the new name using a full catalog if rename is unavoidable elsewhere","Restrict the rewrite catalog registration to rewrite procedure sessions only"],"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":"if (catalog instanceof SparkRewriteTableCatalog) {\n  throw new IllegalStateException(\"renameTable not supported here; use the production catalog\");\n}","typeGuard":"boolean supportsRename(Catalog c) { return !(c instanceof SparkRewriteTableCatalog); }","tryCatchPattern":"try {\n  catalog.renameTable(oldIdent, newIdent);\n} catch (UnsupportedOperationException e) {\n  prodCatalog.renameTable(oldIdent, newIdent);\n}","preventionTips":["Run ALTER TABLE RENAME against a full catalog implementation","Isolate rewrite catalog usage in dedicated sessions","Document that the rewrite catalog implements only staging operations"],"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"}