{"record":{"id":"4dcbd5c4f8dbd334","repo":"apache/iceberg","slug":"cannot-rename-hadoop-tables","errorCode":null,"errorMessage":"Cannot rename Hadoop tables","messagePattern":"Cannot rename Hadoop tables","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/hadoop/HadoopCatalog.java","lineNumber":276,"sourceCode":"      if (lastMetadata == null) {\n        LOG.debug(\"Not an iceberg table: {}\", identifier);\n        return false;\n      } else {\n        if (purge) {\n          // Since the data files and the metadata files may store in different locations,\n          // so it has to call dropTableData to force delete the data file.\n          CatalogUtil.dropTableData(ops.io(), lastMetadata);\n        }\n        return fs.delete(tablePath, true /* recursive */);\n      }\n    } catch (IOException e) {\n      throw new RuntimeIOException(e, \"Failed to delete file: %s\", tablePath);\n    }\n  }\n\n  @Override\n  public void renameTable(TableIdentifier from, TableIdentifier to) {\n    throw new UnsupportedOperationException(\"Cannot rename Hadoop tables\");\n  }\n\n  @Override\n  public void createNamespace(Namespace namespace, Map<String, String> meta) {\n    Preconditions.checkArgument(\n        !namespace.isEmpty(), \"Cannot create namespace with invalid name: %s\", namespace);\n    if (!meta.isEmpty()) {\n      throw new UnsupportedOperationException(\n          \"Cannot create namespace \" + namespace + \": metadata is not supported\");\n    }\n\n    Path nsPath = new Path(warehouseLocation, SLASH.join(namespace.levels()));\n\n    if (isNamespace(nsPath)) {\n      throw new AlreadyExistsException(\"Namespace already exists: %s\", namespace);\n    }\n\n    try {","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/hadoop/HadoopCatalog.java#L258-L294","documentation":"HadoopCatalog.renameTable is unconditionally unsupported: the Hadoop catalog stores tables as directories with no rename metadata support, so calling renameTable always throws UnsupportedOperationException. Applications must use a catalog that supports renames (e.g. Hive, JDBC, REST).","triggerScenarios":"Any call to catalog.renameTable(from, to) on a HadoopCatalog instance — there is no condition; every invocation throws.","commonSituations":"Code written against a HiveCatalog or JDBC catalog being reused with HadoopCatalog, generic 'rename table' admin tooling, or migration scripts moving environments to a filesystem warehouse.","solutions":["Do not call renameTable on HadoopCatalog; restructure code to avoid renames.","Achieve a rename manually: create the new table (e.g. via table copy or data migration) then drop the old one.","Switch to HiveCatalog, JdbcCatalog, or RESTCatalog if renames are a hard requirement.","Wrap the call in a check of catalog type and surface a clear 'unsupported' message to users.","Vote/use the Iceberg RenameTable developments — check your Iceberg version for HadoopCatalog rename support."],"exampleFix":"// before\ncatalog.renameTable(from, to);\n\n// after: guard against unsupported catalogs\nif (catalog instanceof HadoopCatalog) {\n  throw new UnsupportedOperationException(\"Use Hive/JDBC catalog for renames\");\n}\ncatalog.renameTable(from, to);","handlingStrategy":"validation","validationCode":"if (catalog instanceof HadoopCatalog) { throw new UnsupportedOperationException(\"renameTable unsupported on HadoopCatalog\"); }","typeGuard":"if (catalog instanceof HadoopCatalog) { /* use copy+drop or different catalog */ }","tryCatchPattern":"try { catalog.renameTable(from, to); } catch (UnsupportedOperationException e) { // fall back to create-new + migrate + drop }","preventionTips":["Use Hive/JDBC/REST catalogs when renames are required","Centralize rename logic with catalog capability checks","Document HadoopCatalog limitations in team tooling"],"tags":["unsupported-operation","rename","hadoop-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-14T16:17:12.679Z"}