{"record":{"id":"96928d79353e2b46","repo":"prestodb/presto","slug":"accumulo-table-exists-96928d","errorCode":"ACCUMULO_TABLE_EXISTS","errorMessage":"Table %s already exists","messagePattern":"Table (.+?) already exists","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-accumulo/src/main/java/com/facebook/presto/accumulo/AccumuloMetadata.java","lineNumber":138,"sourceCode":"        client.createTable(tableMetadata);\n    }\n\n    @Override\n    public void dropTable(ConnectorSession session, ConnectorTableHandle tableHandle)\n    {\n        AccumuloTableHandle handle = (AccumuloTableHandle) tableHandle;\n        AccumuloTable table = client.getTable(handle.toSchemaTableName());\n        if (table != null) {\n            client.dropTable(table);\n        }\n    }\n\n    @Override\n    public void renameTable(ConnectorSession session, ConnectorTableHandle tableHandle,\n            SchemaTableName newTableName)\n    {\n        if (client.getTable(newTableName) != null) {\n            throw new PrestoException(ACCUMULO_TABLE_EXISTS, \"Table \" + newTableName + \" already exists\");\n        }\n\n        AccumuloTableHandle handle = (AccumuloTableHandle) tableHandle;\n        client.renameTable(handle.toSchemaTableName(), newTableName);\n    }\n\n    @Override\n    public void createView(ConnectorSession session, ConnectorTableMetadata viewMetadata, String viewData, boolean replace)\n    {\n        SchemaTableName viewName = viewMetadata.getTable();\n        if (replace) {\n            client.createOrReplaceView(viewName, viewData);\n        }\n        else {\n            client.createView(viewName, viewData);\n        }\n    }\n","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-accumulo/src/main/java/com/facebook/presto/accumulo/AccumuloMetadata.java#L120-L156","documentation":"AccumuloMetadata.renameTable refuses to rename a table when a table (or view) already exists under the target name in Accumulo. The connector checks client.getTable(newTableName) first and throws ACCUMULO_TABLE_EXISTS to prevent silently overwriting an existing table.","triggerScenarios":"Executing ALTER TABLE ... RENAME TO ... in Presto (or calling renameTable directly) where the destination schema.table already exists as an Accumulo table or registered view.","commonSituations":"Renaming onto a name that was created earlier by another job; case-sensitivity confusion where 'MyTable' vs 'mytable' collide after lowercasing; stale Accumulo table left from a failed previous rename or migration.","solutions":["Choose a different target name that does not already exist.","Drop the existing target table first: DROP TABLE schema.new_name in Presto (or connector.dropTable), then retry the rename.","Check with 'tables list' in the Accumulo shell whether the conflicting table is stale/orphaned and delete it if so.","Verify naming/casing conventions to avoid case-insensitive collisions in the metadata catalog."],"exampleFix":"// before\nALTER TABLE sales.orders RENAME TO sales.orders_backup; -- fails, orders_backup exists\n// after\nDROP TABLE sales.orders_backup;\nALTER TABLE sales.orders RENAME TO sales.orders_backup;","handlingStrategy":"validation","validationCode":"// Check the destination name before renaming:\nSchemaTableName target = new SchemaTableName(\"sales\", \"orders_backup\");\nboolean exists = metadata.listTables(session, target.getSchemaName()).contains(target)\n    || client.getTable(target) != null;\nif (exists) { /* pick another name or drop target first */ }","typeGuard":null,"tryCatchPattern":"try {\n  metadata.renameTable(session, handle, newName);\n} catch (PrestoException e) {\n  if (\"ACCUMULO_TABLE_EXISTS\".equals(e.getErrorCode().getName())) {\n    // choose a different name or DROP TABLE the target, then retry\n  }\n  throw e;\n}","preventionTips":["Always check for the target name's existence before ALTER TABLE ... RENAME.","Use unique, timestamped names for backup tables.","Adopt consistent lowercase naming to avoid case-collisions in the catalog.","Clean up orphaned Accumulo tables after failed DDL operations."],"tags":["accumulo","rename-conflict","table-exists","ddl"],"backgroundTag":"table-already-exists","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}