Skip to content

Commit

Permalink
Create folder if not exits on HDFS write
Browse files Browse the repository at this point in the history
  • Loading branch information
JkSelf authored May 24, 2023
1 parent 57ec320 commit 3e2b6f5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions velox/connectors/hive/storage_adapters/hdfs/HdfsWriteFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ HdfsWriteFile::HdfsWriteFile(
short replication,
int blockSize)
: hdfsClient_(hdfsClient), filePath_(path) {
auto pos = filePath_.rfind("/");
auto parentDir = filePath_.substr(0, pos + 1);
// Check whether the parentDir exist, create it if not exist.
if (hdfsExists(hdfsClient_, parentDir.c_str()) == -1) {
hdfsCreateDirectory(hdfsClient_, parentDir.c_str());
}

hdfsFile_ = hdfsOpenFile(
hdfsClient_,
filePath_.c_str(),
Expand Down

0 comments on commit 3e2b6f5

Please sign in to comment.