{"record":{"id":"8d96accd6ec09e59","repo":"apache/iceberg","slug":"cannot-rename-s-because-the-table-does-not-exist","errorCode":null,"errorMessage":"Cannot rename %s because the table does not exist in Glue","messagePattern":"Cannot rename (.+?) because the table does not exist in Glue","errorType":"exception","errorClass":"NoSuchTableException","httpStatus":null,"severity":"error","filePath":"aws/src/main/java/org/apache/iceberg/aws/glue/GlueCatalog.java","lineNumber":425,"sourceCode":"    String fromTableDbName =\n        IcebergToGlueConverter.getDatabaseName(from, awsProperties.glueCatalogSkipNameValidation());\n    String fromTableName =\n        IcebergToGlueConverter.getTableName(from, awsProperties.glueCatalogSkipNameValidation());\n    String toTableDbName =\n        IcebergToGlueConverter.getDatabaseName(to, awsProperties.glueCatalogSkipNameValidation());\n    String toTableName =\n        IcebergToGlueConverter.getTableName(to, awsProperties.glueCatalogSkipNameValidation());\n    try {\n      GetTableResponse response =\n          glue.getTable(\n              GetTableRequest.builder()\n                  .catalogId(awsProperties.glueCatalogId())\n                  .databaseName(fromTableDbName)\n                  .name(fromTableName)\n                  .build());\n      fromTable = response.table();\n    } catch (EntityNotFoundException e) {\n      throw new NoSuchTableException(\n          e, \"Cannot rename %s because the table does not exist in Glue\", from);\n    }\n\n    // use the same Glue info to create the new table, pointing to the old metadata\n    TableInput.Builder tableInputBuilder =\n        TableInput.builder()\n            .owner(fromTable.owner())\n            .tableType(fromTable.tableType())\n            .parameters(fromTable.parameters())\n            .storageDescriptor(fromTable.storageDescriptor());\n\n    glue.createTable(\n        CreateTableRequest.builder()\n            .catalogId(awsProperties.glueCatalogId())\n            .databaseName(toTableDbName)\n            .tableInput(tableInputBuilder.name(toTableName).build())\n            .build());\n    LOG.info(\"created rename destination table {}\", to);","sourceCodeStart":407,"sourceCodeEnd":443,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/aws/src/main/java/org/apache/iceberg/aws/glue/GlueCatalog.java#L407-L443","documentation":"GlueCatalog.renameTable throws NoSuchTableException when the Glue GetTable call for the source table fails with EntityNotFoundException. It means the fully-qualified source table name (`db.table`) does not correspond to an existing Glue table in the configured catalog, so there is nothing to rename.","triggerScenarios":"Calling catalog.renameTable(from, to) where `from` was already dropped, never created, or the database name is misspelled; or the Glue table exists in a different catalog ID / region than awsProperties.glueCatalogId targets.","commonSituations":"Typos in table or database names; concurrent pipelines where another job dropped the table between the caller's existence check and the rename; pointing the catalog at the wrong AWS account/region; case-sensitivity mismatches between Iceberg identifiers and Glue names.","solutions":["Verify the source table exists with `tableExists(from)` or `glue.getTable(...)` before renaming, and check for typos in the database and table name.","Confirm awsProperties.glueCatalogId() and the client region point to the account/region where the table actually lives.","Handle the race where another process dropped the table: re-check and recreate the table if the drop was unintended, or skip the rename.","Check IAM permissions — a denied GetTable can surface as not-found; ensure the role can read the table in Glue."],"exampleFix":"// before\ncatalog.renameTable(\"sales.events_old\", \"sales.events\");\n\n// after\nTableIdentifier from = TableIdentifier.of(\"sales\", \"events_old\");\nif (catalog.tableExists(from)) {\n  catalog.renameTable(from, TableIdentifier.of(\"sales\", \"events\"));\n} else {\n  LOG.warn(\"Skipping rename, source table {} does not exist\", from);\n}","handlingStrategy":"try-catch","validationCode":"TableIdentifier from = TableIdentifier.of(\"sales\", \"events_old\");\nif (!catalog.tableExists(from)) {\n  throw new IllegalArgumentException(\"Source table \" + from + \" does not exist\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  catalog.renameTable(from, to);\n} catch (NoSuchTableException e) {\n  LOG.error(\"Rename failed, source {} missing in Glue: {}\", from, e.getMessage());\n}","preventionTips":["Always check tableExists(from) before renameTable","Verify glueCatalogId and region match the environment holding the table","Coordinate table drops across pipelines to avoid racing renames"],"tags":["aws","glue","catalog","nosuchtable","rename"],"backgroundTag":"entity-not-found","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"}