Skip to content

Commit 9a19fde

Browse files
committed
1
1 parent 37a8ca8 commit 9a19fde

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

be/src/io/file_factory.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class FileFactory {
107107
static Status create_pipe_reader(const TUniqueId& load_id, io::FileReaderSPtr* file_reader,
108108
RuntimeState* runtime_state, bool need_schema);
109109

110-
static TFileType::type convert_storage_type(TStorageBackendType::type type) {
110+
static Result<TFileType::type> convert_storage_type(TStorageBackendType::type type) {
111111
switch (type) {
112112
case TStorageBackendType::LOCAL:
113113
return TFileType::FILE_LOCAL;
@@ -120,9 +120,8 @@ class FileFactory {
120120
case TStorageBackendType::HDFS:
121121
return TFileType::FILE_HDFS;
122122
default:
123-
throw Exception(Status::FatalError("not match type to convert, from type:{}", type));
123+
return ResultError(Status::FatalError("not match type to convert, from type:{}", type));
124124
}
125-
throw Exception(Status::FatalError("__builtin_unreachable"));
126125
}
127126

128127
private:

be/src/service/internal_service.cpp

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -725,14 +725,23 @@ void PInternalService::outfile_write_success(google::protobuf::RpcController* co
725725
}
726726
}
727727

728-
auto&& res = FileFactory::create_file_writer(
729-
FileFactory::convert_storage_type(result_file_sink.storage_backend_type),
730-
ExecEnv::GetInstance(), file_options.broker_addresses,
731-
file_options.broker_properties, file_name,
732-
{
733-
.write_file_cache = false,
734-
.sync_file_data = false,
735-
});
728+
auto file_type_res =
729+
FileFactory::convert_storage_type(result_file_sink.storage_backend_type);
730+
if (!file_type_res.has_value()) [[unlikely]] {
731+
st = std::move(file_type_res).error();
732+
st.to_protobuf(result->mutable_status());
733+
LOG(WARNING) << "encounter unkonw type=" << result_file_sink.storage_backend_type
734+
<< ", st=" << st;
735+
return;
736+
}
737+
738+
auto&& res = FileFactory::create_file_writer(file_type_res.value(), ExecEnv::GetInstance(),
739+
file_options.broker_addresses,
740+
file_options.broker_properties, file_name,
741+
{
742+
.write_file_cache = false,
743+
.sync_file_data = false,
744+
});
736745
using T = std::decay_t<decltype(res)>;
737746
if (!res.has_value()) [[unlikely]] {
738747
st = std::forward<T>(res).error();

be/src/vec/sink/writer/vfile_result_writer.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,10 @@ Status VFileResultWriter::_create_next_file_writer() {
118118
}
119119

120120
Status VFileResultWriter::_create_file_writer(const std::string& file_name) {
121+
auto file_type = DORIS_TRY(FileFactory::convert_storage_type(_storage_type));
121122
_file_writer_impl = DORIS_TRY(FileFactory::create_file_writer(
122-
FileFactory::convert_storage_type(_storage_type), _state->exec_env(),
123-
_file_opts->broker_addresses, _file_opts->broker_properties, file_name,
123+
file_type, _state->exec_env(), _file_opts->broker_addresses,
124+
_file_opts->broker_properties, file_name,
124125
{
125126
.write_file_cache = false,
126127
.sync_file_data = false,

0 commit comments

Comments
 (0)