[fix](insert)fix hive table sink write path (#32587)

issue: #31442

fix hive table sink write path to hdfs://${hdfs_root}/tmp/.doris_staging/${user}
This commit is contained in:
slothever
2024-03-22 10:37:26 +08:00
committed by morningman
parent c68b353017
commit 70489fe749
2 changed files with 8 additions and 2 deletions

View File

@ -43,6 +43,7 @@ import java.nio.file.InvalidPathException;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class LocationPath {
private static final Logger LOG = LogManager.getLogger(LocationPath.class);
@ -398,6 +399,12 @@ public class LocationPath {
return new Path(location);
}
public static String getTempWritePath(String loc, String prefix) {
Path tempRoot = new Path(loc, prefix);
Path tempPath = new Path(tempRoot, UUID.randomUUID().toString().replace("-", ""));
return tempPath.toString();
}
@Override
public String toString() {
return get();

View File

@ -47,7 +47,6 @@ import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
public class HiveTableSink extends DataSink {
@ -153,7 +152,7 @@ public class HiveTableSink extends DataSink {
private String createTempPath(String location) {
String user = ConnectContext.get().getUserIdentity().getQualifiedUser();
return location + "/.doris_staging/" + user + "/" + UUID.randomUUID().toString().replace("-", "");
return LocationPath.getTempWritePath(location, "/tmp/.doris_staging/" + user);
}
private void setCompressType(THiveTableSink tSink, TFileFormatType formatType) {