prestodb/presto · error · IllegalArgumentException
Target table already exists:
Error message
Target table already exists:
What it means
TestingMetadata.renameTable (and related DDL paths): the rename/create target table already exists in this in-memory test connector. This sentinel guard lets tests exercise already-exists behavior without a real metastore.
Source
Thrown at presto-main-base/src/main/java/com/facebook/presto/testing/TestingMetadata.java:184
@Override
public List<SchemaTableName> listTables(ConnectorSession session, Optional<String> schemaName)
{
ImmutableList.Builder<SchemaTableName> builder = ImmutableList.builder();
for (SchemaTableName tableName : tables.keySet()) {
if (schemaName.map(tableName.getSchemaName()::equals).orElse(true)) {
builder.add(tableName);
}
}
return builder.build();
}
@Override
public void renameTable(ConnectorSession session, ConnectorTableHandle tableHandle, SchemaTableName newTableName)
{
// TODO: use locking to do this properly
ConnectorTableMetadata table = getTableMetadata(session, tableHandle);
if (tables.putIfAbsent(newTableName, table) != null) {
throw new IllegalArgumentException("Target table already exists: " + newTableName);
}
tables.remove(table.getTable(), table);
}
@Override
public void createTable(ConnectorSession session, ConnectorTableMetadata tableMetadata, boolean ignoreExisting)
{
ConnectorTableMetadata existingTable = tables.putIfAbsent(tableMetadata.getTable(), tableMetadata);
if (existingTable != null && !ignoreExisting) {
throw new IllegalArgumentException("Target table already exists: " + tableMetadata.getTable());
}
}
@Override
public void dropTable(ConnectorSession session, ConnectorTableHandle tableHandle)
{
tables.remove(getTableName(tableHandle));
}View on GitHub (pinned to 55bb57d202)
Solutions
- Choose a new table name that does not exist
- Drop the target table first in the test
- Use the replace/overwrite flag where the test API supports it
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at presto-main-base/src/main/java/com/facebook/presto/testing/TestingMetadata.java:184 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/9d20fcd8a6b89952.
Report an issue: GitHub.