prestodb/presto · error · PrestoException
ACCUMULO_TABLE_EXISTS
ACCUMULO_TABLE_EXISTS
Error message
Table %s already exists
What it means
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.
Source
Thrown at presto-accumulo/src/main/java/com/facebook/presto/accumulo/AccumuloMetadata.java:138
client.createTable(tableMetadata);
}
@Override
public void dropTable(ConnectorSession session, ConnectorTableHandle tableHandle)
{
AccumuloTableHandle handle = (AccumuloTableHandle) tableHandle;
AccumuloTable table = client.getTable(handle.toSchemaTableName());
if (table != null) {
client.dropTable(table);
}
}
@Override
public void renameTable(ConnectorSession session, ConnectorTableHandle tableHandle,
SchemaTableName newTableName)
{
if (client.getTable(newTableName) != null) {
throw new PrestoException(ACCUMULO_TABLE_EXISTS, "Table " + newTableName + " already exists");
}
AccumuloTableHandle handle = (AccumuloTableHandle) tableHandle;
client.renameTable(handle.toSchemaTableName(), newTableName);
}
@Override
public void createView(ConnectorSession session, ConnectorTableMetadata viewMetadata, String viewData, boolean replace)
{
SchemaTableName viewName = viewMetadata.getTable();
if (replace) {
client.createOrReplaceView(viewName, viewData);
}
else {
client.createView(viewName, viewData);
}
}
View on GitHub (pinned to 55bb57d202)
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.
Example fix
// before ALTER TABLE sales.orders RENAME TO sales.orders_backup; -- fails, orders_backup exists // after DROP TABLE sales.orders_backup; ALTER TABLE sales.orders RENAME TO sales.orders_backup;
Defensive patterns
Strategy: validation
Validate before calling
// Check the destination name before renaming:
SchemaTableName target = new SchemaTableName("sales", "orders_backup");
boolean exists = metadata.listTables(session, target.getSchemaName()).contains(target)
|| client.getTable(target) != null;
if (exists) { /* pick another name or drop target first */ } Try / catch
try {
metadata.renameTable(session, handle, newName);
} catch (PrestoException e) {
if ("ACCUMULO_TABLE_EXISTS".equals(e.getErrorCode().getName())) {
// choose a different name or DROP TABLE the target, then retry
}
throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/96928d79353e2b46.
Report an issue: GitHub.