{"record":{"id":"de55e7263290835a","repo":"apache/iceberg","slug":"does-not-support-renaming-tables-de55e7","errorCode":null,"errorMessage":" does not support renaming tables","messagePattern":" does not support renaming tables","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/SparkRewriteTableCatalog.java","lineNumber":97,"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":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/SparkRewriteTableCatalog.java#L79-L115","documentation":"renameTable on SparkRewriteTableCatalog throws UnsupportedOperationException because renaming is not supported by this staged-rewrite-only catalog adapter. Like drop/purge, it is intentionally unimplemented; the class only implements createTable/instantiateTable/stageReplace paths needed for CREATE OR REPLACE.","triggerScenarios":"Calling ALTER TABLE ... RENAME TO on a table resolved through SparkRewriteTableCatalog, or calling renameTable directly on an instance.","commonSituations":"Spark session catalog handling renames of non-Iceberg session tables via this adapter; migration scripts that assume spark_catalog supports rename for all table types.","solutions":["Rename through the real underlying catalog (Hive Metastore, JDBC, etc.) rather than the Spark rewrite adapter","Register an Iceberg SparkCatalog and perform ALTER TABLE ... RENAME TO against it","Use engine-neutral APIs (e.g. Hive client) if the table is a non-Iceberg session table"],"exampleFix":"// before\nsparkRewriteCatalog.renameTable(from, to);\n// after\nspark.sql(\"ALTER TABLE iceberg.db.tbl RENAME TO iceberg.db.tbl_new\");","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  catalog.renameTable(from, to);\n} catch (UnsupportedOperationException e) {\n  // delegate rename to the underlying metastore/catalog\n}","preventionTips":["Issue renames against the true backing catalog (Hive/JDBC/REST), not the rewrite adapter","Document that SparkRewriteTableCatalog only supports staged create/replace paths"],"tags":["spark","catalog","unsupported-operation","rename"],"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"}