This is an automated email from the ASF dual-hosted git repository.
weixiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 693a4852218 [fix](cloud): fix parent directory doesn't exist in
HdfsFileWriter (#33985)
693a4852218 is described below
commit 693a48522187546ec1e1a8519336524c6cb9baa6
Author: spaces-x <[email protected]>
AuthorDate: Thu Apr 25 15:25:23 2024 +0800
[fix](cloud): fix parent directory doesn't exist in HdfsFileWriter (#33985)
Co-authored-by: weixiang06 <[email protected]>
---
be/src/io/fs/hdfs_file_writer.cpp | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/be/src/io/fs/hdfs_file_writer.cpp
b/be/src/io/fs/hdfs_file_writer.cpp
index d15745ebf37..c596c0e290f 100644
--- a/be/src/io/fs/hdfs_file_writer.cpp
+++ b/be/src/io/fs/hdfs_file_writer.cpp
@@ -281,6 +281,21 @@ Result<FileWriterPtr> HdfsFileWriter::create(Path
full_path, std::shared_ptr<Hdf
const std::string& fs_name,
const FileWriterOptions* opts) {
auto path = convert_path(full_path, fs_name);
+#ifdef USE_LIBHDFS3
+ std::string hdfs_dir = path.parent_path().string();
+ int exists = hdfsExists(handler->hdfs_fs, hdfs_dir.c_str());
+ if (exists != 0) {
+ VLOG_NOTICE << "hdfs dir doesn't exist, create it: " << hdfs_dir;
+ int ret = hdfsCreateDirectory(handler->hdfs_fs, hdfs_dir.c_str());
+ if (ret != 0) {
+ std::stringstream ss;
+ ss << "create dir failed. "
+ << " fs_name: " << fs_name << " path: " << hdfs_dir << ", err:
" << hdfs_error();
+ LOG(WARNING) << ss.str();
+ return ResultError(Status::InternalError(ss.str()));
+ }
+ }
+#endif
// open file
hdfsFile hdfs_file = nullptr;
{
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]