Skip to content

Commit

Permalink
Fix Build due to ClickHouse/ClickHouse#71105
Browse files Browse the repository at this point in the history
  • Loading branch information
baibaichen committed Nov 1, 2024
1 parent 05c0ab7 commit 8b7871b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cpp-ch/local-engine/Storages/Output/WriteBufferBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace DB
{
namespace ErrorCodes
{
extern const int BAD_ARGUMENTS;
extern const int BAD_ARGUMENTS;
}
}

Expand Down Expand Up @@ -78,14 +78,16 @@ class HDFSFileWriteBufferBuilder : public WriteBufferBuilder

auto builder = DB::createHDFSBuilder(new_file_uri, context->getConfigRef());
auto fs = DB::createHDFSFS(builder.get());
auto first = new_file_uri.find('/', new_file_uri.find("//") + 2);
auto begin_of_path = new_file_uri.find('/', new_file_uri.find("//") + 2);
auto last = new_file_uri.find_last_of('/');
auto dir = new_file_uri.substr(first, last - first);
auto dir = new_file_uri.substr(begin_of_path, last - begin_of_path);
if (hdfsCreateDirectory(fs.get(), dir.c_str()))
throw DB::Exception(DB::ErrorCodes::BAD_ARGUMENTS, "Cannot create dir for {} because {}", dir, std::string(hdfsGetLastError()));

const std::string hdfs_file_path = new_file_uri.substr(begin_of_path);
const std::string hdfs_uri_without_path = new_file_uri.substr(0, begin_of_path);
DB::WriteSettings write_settings;
return std::make_unique<DB::WriteBufferFromHDFS>(new_file_uri, context->getConfigRef(), 0, write_settings);
return std::make_unique<DB::WriteBufferFromHDFS>(hdfs_uri_without_path, hdfs_file_path, context->getConfigRef(), 0, write_settings);
}
};
#endif
Expand Down

0 comments on commit 8b7871b

Please sign in to comment.