prestodb/presto · error · PrestoException
HIVE_PATH_ALREADY_EXISTS
HIVE_PATH_ALREADY_EXISTS
Error message
Target directory for new partition '%s' of table '%s.%s' already exists: %s
What it means
getWriterParametersForNewPartitionedTable: when the computed write path for the new partition equals the table's target path and that directory already exists, creation of the partition would overwrite existing data, so it is refused.
Source
Thrown at presto-hive/src/main/java/com/facebook/presto/hive/HiveWriterFactory.java:455
private WriterParameters getWriterParametersForNewUnpartitionedTable()
{
return new WriterParameters(
UpdateMode.NEW,
createHiveSchema(dataColumns),
locationService.getTableWriteInfo(locationHandle),
fromHiveStorageFormat(storageFormat));
}
private WriterParameters getWriterParametersForNewPartitionedTable(String partitionName)
{
WriteInfo writeInfo = locationService.getPartitionWriteInfo(locationHandle, Optional.empty(), partitionName);
if (!writeInfo.getWriteMode().isWritePathSameAsTargetPath()) {
// When target path is different from write path,
// verify that the target directory for the partition does not already exist
HdfsContext context = new HdfsContext(session, schemaName, tableName, locationHandle.getTargetPath().toString(), true);
if (MetastoreUtil.pathExists(context, hdfsEnvironment, writeInfo.getTargetPath())) {
throw new PrestoException(HIVE_PATH_ALREADY_EXISTS, format(
"Target directory for new partition '%s' of table '%s.%s' already exists: %s",
partitionName,
schemaName,
tableName,
writeInfo.getTargetPath()));
}
}
return new WriterParameters(
UpdateMode.NEW,
createHiveSchema(dataColumns),
writeInfo,
fromHiveStorageFormat(storageFormat));
}
private WriterParameters getWriterParametersForExistingUnpartitionedTable(OptionalInt bucketNumber)
{
// Note: temporary table is always empty at this step
if (!table.getTableType().equals(TEMPORARY_TABLE)) {View on GitHub (pinned to 55bb57d202)
Solutions
- Drop or clean the stale partition directory
- Verify no concurrent write created the partition
- Choose a different table location
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at presto-hive/src/main/java/com/facebook/presto/hive/HiveWriterFactory.java:455 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/1bf7d06ae47ab644.
Report an issue: GitHub.