{"record":{"id":"650e8f1878f13294","repo":"apache/iceberg","slug":"sparkcachedtablecatalog-does-not-support-renaming","errorCode":null,"errorMessage":"SparkCachedTableCatalog does not support renaming tables","messagePattern":"SparkCachedTableCatalog does not support renaming 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":118,"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 SparkTable load(Identifier ident) throws NoSuchTableException {\n    Preconditions.checkArgument(\n        ident.namespace().length == 0, CLASS_NAME + \" does not support namespaces\");\n\n    Pair<String, List<String>> parsedIdent = parseIdent(ident);\n    String key = parsedIdent.first();","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/SparkCachedTableCatalog.java#L100-L136","documentation":"SparkCachedTableCatalog.renameTable() throws UnsupportedOperationException in all cases. Renaming is a metadata mutation on the owning catalog; the cached catalog is a read-only projection and cannot move or re-key table entries.","triggerScenarios":"Calling SparkCachedTableCatalog.renameTable(oldIdent, newIdent), or ALTER TABLE ... RENAME TO in Spark SQL when either identifier resolves to the cached catalog.","commonSituations":"Migration scripts renaming tables after a cached read; generic catalog-abstraction layers that issue rename uniformly; users expecting the cached alias to be renamable.","solutions":["Perform the rename against the real catalog with fully qualified identifiers (ALTER TABLE spark_catalog.db.old RENAME TO ...).","Programmatically use the owning SupportsRename catalog's renameTable method.","If only a different cached alias is needed, load the table again under the new key instead of renaming."],"exampleFix":"// before\ncachedCatalog.renameTable(oldIdent, newIdent);\n\n// after\nspark.sql(\"ALTER TABLE spark_catalog.db.old_name RENAME TO spark_catalog.db.new_name\");","handlingStrategy":"validation","validationCode":"if (catalog instanceof SparkCachedTableCatalog) {\n  throw new IllegalArgumentException(\"renameTable is not supported on SparkCachedTableCatalog; use the owning catalog\");\n}","typeGuard":"boolean canRename = !(catalog instanceof SparkCachedTableCatalog);","tryCatchPattern":"try {\n  catalog.renameTable(oldIdent, newIdent);\n} catch (UnsupportedOperationException e) {\n  // rename via spark_catalog / owning catalog\n}","preventionTips":["Perform renames with fully qualified identifiers in the owning catalog.","If only a different cache key is needed, re-load the table under the new key instead of renaming.","Keep cached-catalog usage confined to read/query paths."],"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"}