Skip to content

Commit b0b1f22

Browse files
authored
[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}
1 parent d584532 commit b0b1f22

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

‎fe/fe-core/src/main/java/org/apache/doris/common/util/LocationPath.java‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import java.nio.file.Paths;
4444
import java.util.HashMap;
4545
import java.util.Map;
46+
import java.util.UUID;
4647

4748
public class LocationPath {
4849
private static final Logger LOG = LogManager.getLogger(LocationPath.class);
@@ -398,6 +399,12 @@ public Path getPath() {
398399
return new Path(location);
399400
}
400401

402+
public static String getTempWritePath(String loc, String prefix) {
403+
Path tempRoot = new Path(loc, prefix);
404+
Path tempPath = new Path(tempRoot, UUID.randomUUID().toString().replace("-", ""));
405+
return tempPath.toString();
406+
}
407+
401408
@Override
402409
public String toString() {
403410
return get();

‎fe/fe-core/src/main/java/org/apache/doris/planner/HiveTableSink.java‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
import java.util.List;
4848
import java.util.Optional;
4949
import java.util.Set;
50-
import java.util.UUID;
5150
import java.util.stream.Collectors;
5251

5352
public class HiveTableSink extends DataSink {
@@ -153,7 +152,7 @@ public void bindDataSink(List<Column> insertCols, Optional<InsertCommandContext>
153152

154153
private String createTempPath(String location) {
155154
String user = ConnectContext.get().getUserIdentity().getUser();
156-
return location + "/.doris_staging/" + user + "/" + UUID.randomUUID().toString().replace("-", "");
155+
return LocationPath.getTempWritePath(location, "/tmp/.doris_staging/" + user);
157156
}
158157

159158
private void setCompressType(THiveTableSink tSink, TFileFormatType formatType) {

0 commit comments

Comments
 (0)