Skip to content

Commit 4c3ae1c

Browse files
committed
1
1 parent a3ae7cb commit 4c3ae1c

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
@@ -735,14 +735,23 @@ void PInternalService::outfile_write_success(google::protobuf::RpcController* co
735735
}
736736
}
737737

738-
auto&& res = FileFactory::create_file_writer(
739-
FileFactory::convert_storage_type(result_file_sink.storage_backend_type),
740-
ExecEnv::GetInstance(), file_options.broker_addresses,
741-
file_options.broker_properties, file_name,
742-
{
743-
.write_file_cache = false,
744-
.sync_file_data = false,
745-
});
738+
auto file_type_res =
739+
FileFactory::convert_storage_type(result_file_sink.storage_backend_type);
740+
if (!file_type_res.has_value()) [[unlikely]] {
741+
st = std::move(file_type_res).error();
742+
st.to_protobuf(result->mutable_status());
743+
LOG(WARNING) << "encounter unkonw type=" << result_file_sink.storage_backend_type
744+
<< ", st=" << st;
745+
return;
746+
}
747+
748+
auto&& res = FileFactory::create_file_writer(file_type_res.value(), ExecEnv::GetInstance(),
749+
file_options.broker_addresses,
750+
file_options.broker_properties, file_name,
751+
{
752+
.write_file_cache = false,
753+
.sync_file_data = false,
754+
});
746755
using T = std::decay_t<decltype(res)>;
747756
if (!res.has_value()) [[unlikely]] {
748757
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)