Check if target file exists before rename
HDFS fails if the target file exists, but other file systems such as
the local file system do not (and thus will replace the target file).
@@ -1363,7 +1363,7 @@ public class SemiTransactionalHiveMetastore
return;
}
try {
- if (!fileSystem.rename(source, target)) {
+ if (fileSystem.exists(target) || !fileSystem.rename(source, target)) {
throw new PrestoException(HIVE_FILESYSTEM_ERROR, format("Error moving data files from %s to final location %s", source, target));
}
}
