This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.1 by this push:
     new 433c1bc9ffa [cherry-pick](branch-21) replace the LOG(FATAL) to throw 
Exception in query execute layer (#38144) (#44183)
433c1bc9ffa is described below

commit 433c1bc9ffad83e6a1221476592e56f38c903fd0
Author: zhangstar333 <zhangs...@selectdb.com>
AuthorDate: Tue Nov 19 17:28:20 2024 +0800

    [cherry-pick](branch-21) replace the LOG(FATAL) to throw Exception in query 
execute layer (#38144) (#44183)
    
    cherry-pick from master https://github.com/apache/doris/pull/38144
---
 .../aggregate_function_distinct.cpp                |  5 +--
 .../aggregate_function_min_max.h                   |  8 ++---
 .../aggregate_functions/aggregate_function_null.h  |  8 +++--
 .../aggregate_function_reader_first_last.h         | 12 +++++---
 .../aggregate_function_window.h                    | 12 +++++---
 be/src/vec/aggregate_functions/factory_helpers.h   | 12 +++++---
 be/src/vec/data_types/data_type.cpp                | 17 +++++++---
 be/src/vec/data_types/data_type_array.h            |  3 +-
 be/src/vec/data_types/data_type_bitmap.h           |  3 +-
 be/src/vec/data_types/data_type_decimal.h          |  3 +-
 be/src/vec/data_types/data_type_factory.cpp        |  2 +-
 .../vec/data_types/data_type_fixed_length_object.h |  3 +-
 be/src/vec/data_types/data_type_hll.h              |  2 +-
 be/src/vec/data_types/data_type_map.h              |  2 +-
 be/src/vec/data_types/data_type_nothing.cpp        |  4 +--
 be/src/vec/data_types/data_type_nothing.h          | 10 ++++--
 be/src/vec/data_types/data_type_nullable.cpp       |  3 +-
 be/src/vec/data_types/data_type_object.h           |  6 +++-
 be/src/vec/data_types/data_type_quantilestate.h    |  4 ++-
 be/src/vec/data_types/data_type_struct.cpp         |  6 ++--
 be/src/vec/data_types/data_type_struct.h           |  3 +-
 be/src/vec/data_types/data_type_time.h             |  2 +-
 be/src/vec/data_types/data_type_time_v2.h          |  2 +-
 .../vec/data_types/serde/data_type_decimal_serde.h |  3 +-
 .../vec/data_types/serde/data_type_number_serde.h  |  3 +-
 .../vec/functions/array/function_array_cum_sum.cpp |  8 +++--
 .../functions/array/function_array_difference.h    |  7 +++--
 .../functions/array/function_array_enumerate.cpp   |  7 +++--
 .../array/function_array_enumerate_uniq.cpp        | 12 +++++---
 be/src/vec/functions/function.h                    | 26 ++++++++++------
 be/src/vec/functions/function_binary_arithmetic.h  | 12 +++++---
 be/src/vec/functions/function_cast.h               | 10 +++---
 .../function_date_or_datetime_computation.h        | 14 +++++----
 .../function_date_or_datetime_to_something.h       | 30 +++++++++---------
 be/src/vec/functions/function_helpers.cpp          | 16 ++++++----
 be/src/vec/functions/function_jsonb.cpp            |  3 +-
 be/src/vec/functions/function_string.cpp           |  5 +--
 be/src/vec/functions/function_string_to_string.h   |  5 +--
 be/src/vec/functions/function_unary_arithmetic.h   |  5 +--
 be/src/vec/functions/function_variadic_arguments.h |  8 +++--
 be/src/vec/functions/functions_comparison.h        | 18 ++++++-----
 be/src/vec/functions/functions_logical.cpp         | 20 +++++++-----
 be/src/vec/functions/if.cpp                        |  3 +-
 be/src/vec/functions/round.h                       | 36 ++++++++++++++--------
 be/src/vec/json/json_parser.cpp                    |  6 ++--
 45 files changed, 243 insertions(+), 146 deletions(-)

diff --git a/be/src/vec/aggregate_functions/aggregate_function_distinct.cpp 
b/be/src/vec/aggregate_functions/aggregate_function_distinct.cpp
index 51138fe8c42..fce58b38688 100644
--- a/be/src/vec/aggregate_functions/aggregate_function_distinct.cpp
+++ b/be/src/vec/aggregate_functions/aggregate_function_distinct.cpp
@@ -45,8 +45,9 @@ public:
 
     DataTypes transform_arguments(const DataTypes& arguments) const override {
         if (arguments.empty()) {
-            LOG(FATAL)
-                    << "Incorrect number of arguments for aggregate function 
with Distinct suffix";
+            throw doris::Exception(
+                    ErrorCode::INTERNAL_ERROR,
+                    "Incorrect number of arguments for aggregate function with 
Distinct suffix");
         }
         return arguments;
     }
diff --git a/be/src/vec/aggregate_functions/aggregate_function_min_max.h 
b/be/src/vec/aggregate_functions/aggregate_function_min_max.h
index 16d7278adcd..3d567164586 100644
--- a/be/src/vec/aggregate_functions/aggregate_function_min_max.h
+++ b/be/src/vec/aggregate_functions/aggregate_function_min_max.h
@@ -514,10 +514,10 @@ public:
         if (StringRef(Data::name()) == StringRef("min") ||
             StringRef(Data::name()) == StringRef("max")) {
             if (!type->is_comparable()) {
-                LOG(FATAL) << fmt::format(
-                        "Illegal type {} of argument of aggregate function {} 
because the values "
-                        "of that data type are not comparable",
-                        type->get_name(), get_name());
+                throw doris::Exception(ErrorCode::INTERNAL_ERROR,
+                                       "Illegal type {} of argument of 
aggregate function {} "
+                                       "because the values of that data type 
are not comparable",
+                                       type->get_name(), get_name());
             }
         }
     }
diff --git a/be/src/vec/aggregate_functions/aggregate_function_null.h 
b/be/src/vec/aggregate_functions/aggregate_function_null.h
index 53cad4e3b15..b2fbe1b2e7f 100644
--- a/be/src/vec/aggregate_functions/aggregate_function_null.h
+++ b/be/src/vec/aggregate_functions/aggregate_function_null.h
@@ -280,12 +280,14 @@ public:
                       nested_function_, arguments),
               number_of_arguments(arguments.size()) {
         if (number_of_arguments == 1) {
-            LOG(FATAL)
-                    << "Logical error: single argument is passed to 
AggregateFunctionNullVariadic";
+            throw doris::Exception(
+                    ErrorCode::INTERNAL_ERROR,
+                    "Logical error: single argument is passed to 
AggregateFunctionNullVariadic");
         }
 
         if (number_of_arguments > MAX_ARGS) {
-            LOG(FATAL) << fmt::format(
+            throw doris::Exception(
+                    ErrorCode::INTERNAL_ERROR,
                     "Maximum number of arguments for aggregate function with 
Nullable types is {}",
                     size_t(MAX_ARGS));
         }
diff --git 
a/be/src/vec/aggregate_functions/aggregate_function_reader_first_last.h 
b/be/src/vec/aggregate_functions/aggregate_function_reader_first_last.h
index 41ad71ad8b0..d11350a5b3a 100644
--- a/be/src/vec/aggregate_functions/aggregate_function_reader_first_last.h
+++ b/be/src/vec/aggregate_functions/aggregate_function_reader_first_last.h
@@ -225,19 +225,23 @@ public:
     void add_range_single_place(int64_t partition_start, int64_t 
partition_end, int64_t frame_start,
                                 int64_t frame_end, AggregateDataPtr place, 
const IColumn** columns,
                                 Arena* arena) const override {
-        LOG(FATAL) << "ReaderFunctionData do not support 
add_range_single_place";
+        throw doris::Exception(ErrorCode::INTERNAL_ERROR,
+                               "ReaderFunctionData do not support 
add_range_single_place");
         __builtin_unreachable();
     }
     void merge(AggregateDataPtr place, ConstAggregateDataPtr rhs, Arena*) 
const override {
-        LOG(FATAL) << "ReaderFunctionData do not support merge";
+        throw doris::Exception(ErrorCode::INTERNAL_ERROR,
+                               "ReaderFunctionData do not support merge");
         __builtin_unreachable();
     }
     void serialize(ConstAggregateDataPtr place, BufferWritable& buf) const 
override {
-        LOG(FATAL) << "ReaderFunctionData do not support serialize";
+        throw doris::Exception(ErrorCode::INTERNAL_ERROR,
+                               "ReaderFunctionData do not support serialize");
         __builtin_unreachable();
     }
     void deserialize(AggregateDataPtr place, BufferReadable& buf, Arena*) 
const override {
-        LOG(FATAL) << "ReaderFunctionData do not support deserialize";
+        throw doris::Exception(ErrorCode::INTERNAL_ERROR,
+                               "ReaderFunctionData do not support 
deserialize");
         __builtin_unreachable();
     }
 
diff --git a/be/src/vec/aggregate_functions/aggregate_function_window.h 
b/be/src/vec/aggregate_functions/aggregate_function_window.h
index 2c290c5fd07..d293383feb6 100644
--- a/be/src/vec/aggregate_functions/aggregate_function_window.h
+++ b/be/src/vec/aggregate_functions/aggregate_function_window.h
@@ -558,19 +558,23 @@ public:
 
     void add(AggregateDataPtr place, const IColumn** columns, ssize_t row_num,
              Arena* arena) const override {
-        LOG(FATAL) << "WindowFunctionLeadLagData do not support add";
+        throw doris::Exception(ErrorCode::INTERNAL_ERROR,
+                               "WindowFunctionLeadLagData do not support add");
         __builtin_unreachable();
     }
     void merge(AggregateDataPtr place, ConstAggregateDataPtr rhs, Arena*) 
const override {
-        LOG(FATAL) << "WindowFunctionLeadLagData do not support merge";
+        throw doris::Exception(ErrorCode::INTERNAL_ERROR,
+                               "WindowFunctionLeadLagData do not support 
merge");
         __builtin_unreachable();
     }
     void serialize(ConstAggregateDataPtr place, BufferWritable& buf) const 
override {
-        LOG(FATAL) << "WindowFunctionLeadLagData do not support serialize";
+        throw doris::Exception(ErrorCode::INTERNAL_ERROR,
+                               "WindowFunctionLeadLagData do not support 
serialize");
         __builtin_unreachable();
     }
     void deserialize(AggregateDataPtr place, BufferReadable& buf, Arena*) 
const override {
-        LOG(FATAL) << "WindowFunctionLeadLagData do not support deserialize";
+        throw doris::Exception(ErrorCode::INTERNAL_ERROR,
+                               "WindowFunctionLeadLagData do not support 
deserialize");
         __builtin_unreachable();
     }
 
diff --git a/be/src/vec/aggregate_functions/factory_helpers.h 
b/be/src/vec/aggregate_functions/factory_helpers.h
index 0bbedce05ad..553f05c3665 100644
--- a/be/src/vec/aggregate_functions/factory_helpers.h
+++ b/be/src/vec/aggregate_functions/factory_helpers.h
@@ -43,15 +43,17 @@ void assert_arity_at_most(const std::string& name, const 
DataTypes& argument_typ
     }
 
     if constexpr (maximal_arity == 0) {
-        LOG(FATAL) << fmt::format("Aggregate function {} cannot have 
arguments", name);
+        throw doris::Exception(ErrorCode::INTERNAL_ERROR,
+                               "Aggregate function {} cannot have arguments", 
name);
     }
 
     if constexpr (maximal_arity == 1) {
-        LOG(FATAL) << fmt::format("Aggregate function {} requires zero or one 
argument", name);
+        throw doris::Exception(ErrorCode::INTERNAL_ERROR,
+                               "Aggregate function {} requires zero or one 
argument", name);
     }
-
-    LOG(FATAL) << fmt::format("Aggregate function {} requires at most {} 
arguments", name,
-                              maximal_arity);
+    throw doris::Exception(ErrorCode::INTERNAL_ERROR,
+                           "Aggregate function {} requires at most {} 
arguments", name,
+                           maximal_arity);
 }
 
 } // namespace doris::vectorized
diff --git a/be/src/vec/data_types/data_type.cpp 
b/be/src/vec/data_types/data_type.cpp
index e1c12d429ff..046266a39cd 100644
--- a/be/src/vec/data_types/data_type.cpp
+++ b/be/src/vec/data_types/data_type.cpp
@@ -28,6 +28,7 @@
 #include <utility>
 
 #include "common/logging.h"
+#include "common/status.h"
 #include "vec/columns/column.h"
 #include "vec/columns/column_const.h"
 #include "vec/core/field.h"
@@ -80,20 +81,25 @@ ColumnPtr 
IDataType::create_column_const_with_default_value(size_t size) const {
 }
 
 size_t IDataType::get_size_of_value_in_memory() const {
-    LOG(FATAL) << fmt::format("Value of type {} in memory is not of fixed 
size.", get_name());
+    throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
+                           "Value of type {} in memory is not of fixed size.", 
get_name());
     return 0;
 }
 
 void IDataType::to_string(const IColumn& column, size_t row_num, 
BufferWritable& ostr) const {
-    LOG(FATAL) << fmt::format("Data type {} to_string not implement.", 
get_name());
+    throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
+                           "Data type {} to_string ostr not implement.", 
get_name());
 }
 
 std::string IDataType::to_string(const IColumn& column, size_t row_num) const {
-    LOG(FATAL) << fmt::format("Data type {} to_string not implement.", 
get_name());
+    throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
+                           "Data type {} to_string not implement.", 
get_name());
     return "";
 }
 Status IDataType::from_string(ReadBuffer& rb, IColumn* column) const {
-    LOG(FATAL) << fmt::format("Data type {} from_string not implement.", 
get_name());
+    throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
+                           "Data type {} from_string not implement.", 
get_name());
+
     return Status::OK();
 }
 
@@ -180,7 +186,8 @@ PGenericType_TypeId IDataType::get_pdata_type(const 
IDataType* data_type) {
     case TypeIndex::TimeV2:
         return PGenericType::TIMEV2;
     default:
-        LOG(FATAL) << fmt::format("could not mapping type {} to pb type", 
data_type->get_type_id());
+        throw doris::Exception(ErrorCode::INTERNAL_ERROR, "could not mapping 
type {} to pb type",
+                               data_type->get_type_id());
         return PGenericType::UNKNOWN;
     }
 }
diff --git a/be/src/vec/data_types/data_type_array.h 
b/be/src/vec/data_types/data_type_array.h
index 7441538b839..ae58efc0ca1 100644
--- a/be/src/vec/data_types/data_type_array.h
+++ b/be/src/vec/data_types/data_type_array.h
@@ -78,7 +78,8 @@ public:
     Field get_default() const override;
 
     [[noreturn]] Field get_field(const TExprNode& node) const override {
-        LOG(FATAL) << "Unimplemented get_field for array";
+        throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
+                               "Unimplemented get_field for array");
         __builtin_unreachable();
     }
 
diff --git a/be/src/vec/data_types/data_type_bitmap.h 
b/be/src/vec/data_types/data_type_bitmap.h
index 08b46161779..14fc1128ff0 100644
--- a/be/src/vec/data_types/data_type_bitmap.h
+++ b/be/src/vec/data_types/data_type_bitmap.h
@@ -105,7 +105,8 @@ public:
     Field get_default() const override { return BitmapValue::empty_bitmap(); }
 
     [[noreturn]] Field get_field(const TExprNode& node) const override {
-        LOG(FATAL) << "Unimplemented get_field for BitMap";
+        throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
+                               "Unimplemented get_field for BitMap");
         __builtin_unreachable();
     }
 
diff --git a/be/src/vec/data_types/data_type_decimal.h 
b/be/src/vec/data_types/data_type_decimal.h
index 2acae5800d0..d95750c9f25 100644
--- a/be/src/vec/data_types/data_type_decimal.h
+++ b/be/src/vec/data_types/data_type_decimal.h
@@ -299,7 +299,8 @@ public:
     template <typename U>
     T scale_factor_for(const DataTypeDecimal<U>& x, bool) const {
         if (get_scale() < x.get_scale()) {
-            LOG(FATAL) << "Decimal result's scale is less then argiment's one";
+            throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
+                                   "Decimal result's scale is less then 
argument's one");
             __builtin_unreachable();
         }
 
diff --git a/be/src/vec/data_types/data_type_factory.cpp 
b/be/src/vec/data_types/data_type_factory.cpp
index 9c40588ed31..7d77684dbb4 100644
--- a/be/src/vec/data_types/data_type_factory.cpp
+++ b/be/src/vec/data_types/data_type_factory.cpp
@@ -573,7 +573,7 @@ DataTypePtr DataTypeFactory::create_data_type(const 
PColumnMeta& pcolumn) {
         break;
     }
     default: {
-        LOG(FATAL) << fmt::format("Unknown data type: {}", pcolumn.type());
+        throw doris::Exception(ErrorCode::INTERNAL_ERROR, "Unknown data type: 
{}", pcolumn.type());
         return nullptr;
     }
     }
diff --git a/be/src/vec/data_types/data_type_fixed_length_object.h 
b/be/src/vec/data_types/data_type_fixed_length_object.h
index 28ba8fe0f31..53893cc87aa 100644
--- a/be/src/vec/data_types/data_type_fixed_length_object.h
+++ b/be/src/vec/data_types/data_type_fixed_length_object.h
@@ -63,7 +63,8 @@ public:
     Field get_default() const override { return Field(String()); }
 
     [[noreturn]] Field get_field(const TExprNode& node) const override {
-        LOG(FATAL) << "Unimplemented get_field for DataTypeFixedLengthObject";
+        throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
+                               "Unimplemented get_field for 
DataTypeFixedLengthObject");
         __builtin_unreachable();
     }
 
diff --git a/be/src/vec/data_types/data_type_hll.h 
b/be/src/vec/data_types/data_type_hll.h
index f3856baecfb..ab7dc817800 100644
--- a/be/src/vec/data_types/data_type_hll.h
+++ b/be/src/vec/data_types/data_type_hll.h
@@ -89,7 +89,7 @@ public:
     Field get_default() const override { return HyperLogLog::empty(); }
 
     [[noreturn]] Field get_field(const TExprNode& node) const override {
-        LOG(FATAL) << "Unimplemented get_field for HLL";
+        throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR, 
"Unimplemented get_field for HLL");
         __builtin_unreachable();
     }
 
diff --git a/be/src/vec/data_types/data_type_map.h 
b/be/src/vec/data_types/data_type_map.h
index fab925cc6f4..e7cc87cddf7 100644
--- a/be/src/vec/data_types/data_type_map.h
+++ b/be/src/vec/data_types/data_type_map.h
@@ -79,7 +79,7 @@ public:
     Field get_default() const override;
 
     [[noreturn]] Field get_field(const TExprNode& node) const override {
-        LOG(FATAL) << "Unimplemented get_field for map";
+        throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR, 
"Unimplemented get_field for map");
         __builtin_unreachable();
     }
 
diff --git a/be/src/vec/data_types/data_type_nothing.cpp 
b/be/src/vec/data_types/data_type_nothing.cpp
index bd0cb9ae04b..9dc9b873d9a 100644
--- a/be/src/vec/data_types/data_type_nothing.cpp
+++ b/be/src/vec/data_types/data_type_nothing.cpp
@@ -31,13 +31,13 @@ MutableColumnPtr DataTypeNothing::create_column() const {
 }
 
 char* DataTypeNothing::serialize(const IColumn& column, char* buf, int 
be_exec_version) const {
-    LOG(FATAL) << "not support";
+    throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR, "serialize not 
support");
     __builtin_unreachable();
 }
 
 const char* DataTypeNothing::deserialize(const char* buf, IColumn* column,
                                          int be_exec_version) const {
-    LOG(FATAL) << "not support";
+    throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR, "deserialize not 
support");
     __builtin_unreachable();
 }
 
diff --git a/be/src/vec/data_types/data_type_nothing.h 
b/be/src/vec/data_types/data_type_nothing.h
index 71733d6d34c..0e2a77957fb 100644
--- a/be/src/vec/data_types/data_type_nothing.h
+++ b/be/src/vec/data_types/data_type_nothing.h
@@ -77,12 +77,15 @@ public:
     const char* deserialize(const char* buf, IColumn* column, int 
be_exec_version) const override;
 
     [[noreturn]] Field get_default() const override {
-        LOG(FATAL) << "Method get_default() is not implemented for data type " 
<< get_name();
+        throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
+                               "Method get_default() is not implemented for 
data type {}.",
+                               get_name());
         __builtin_unreachable();
     }
 
     [[noreturn]] Field get_field(const TExprNode& node) const override {
-        LOG(FATAL) << "Unimplemented get_field for Nothing";
+        throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
+                               "Unimplemented get_field for Nothing");
         __builtin_unreachable();
     }
 
@@ -93,7 +96,8 @@ public:
 
     bool have_subtypes() const override { return false; }
     DataTypeSerDeSPtr get_serde(int nesting_level = 1) const override {
-        LOG(FATAL) << get_name() << " not support serde";
+        throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
+                               "Method get_serde not support serde {}.", 
get_name());
     };
 };
 
diff --git a/be/src/vec/data_types/data_type_nullable.cpp 
b/be/src/vec/data_types/data_type_nullable.cpp
index b10244c8522..e6963632427 100644
--- a/be/src/vec/data_types/data_type_nullable.cpp
+++ b/be/src/vec/data_types/data_type_nullable.cpp
@@ -212,7 +212,8 @@ Field DataTypeNullable::get_default() const {
 }
 
 size_t DataTypeNullable::get_size_of_value_in_memory() const {
-    LOG(FATAL) << fmt::format("Value of type {} in memory is not of fixed 
size.", get_name());
+    throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
+                           "Value of type {} in memory is not of fixed size.", 
get_name());
     return 0;
 }
 
diff --git a/be/src/vec/data_types/data_type_object.h 
b/be/src/vec/data_types/data_type_object.h
index 5fbd5492466..cc24200cd18 100644
--- a/be/src/vec/data_types/data_type_object.h
+++ b/be/src/vec/data_types/data_type_object.h
@@ -27,8 +27,10 @@
 
 #include <memory>
 #include <ostream>
+#include <sstream>
 #include <string>
 
+#include "common/status.h"
 #include "runtime/define_primitive_type.h"
 #include "runtime/types.h"
 #include "serde/data_type_object_serde.h"
@@ -83,7 +85,9 @@ public:
         if (node.node_type == TExprNodeType::NULL_LITERAL) {
             return {};
         }
-        LOG(FATAL) << "Unkown literal " << node;
+        std::stringstream error_string;
+        node.printTo(error_string);
+        throw doris::Exception(ErrorCode::INTERNAL_ERROR, "Unkown literal {}", 
error_string.str());
         return {};
     }
 
diff --git a/be/src/vec/data_types/data_type_quantilestate.h 
b/be/src/vec/data_types/data_type_quantilestate.h
index c07e1eb3a42..e706427c409 100644
--- a/be/src/vec/data_types/data_type_quantilestate.h
+++ b/be/src/vec/data_types/data_type_quantilestate.h
@@ -24,6 +24,7 @@
 #include <string>
 #include <typeinfo>
 
+#include "common/status.h"
 #include "runtime/define_primitive_type.h"
 #include "serde/data_type_quantilestate_serde.h"
 #include "util/quantile_state.h"
@@ -93,7 +94,8 @@ public:
     Field get_default() const override { return QuantileState(); }
 
     [[noreturn]] Field get_field(const TExprNode& node) const override {
-        LOG(FATAL) << "Unimplemented get_field for quantilestate";
+        throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
+                               "Unimplemented get_field for quantile state");
         __builtin_unreachable();
     }
 
diff --git a/be/src/vec/data_types/data_type_struct.cpp 
b/be/src/vec/data_types/data_type_struct.cpp
index 8a28a0998cc..3cef6c9701a 100644
--- a/be/src/vec/data_types/data_type_struct.cpp
+++ b/be/src/vec/data_types/data_type_struct.cpp
@@ -74,7 +74,8 @@ DataTypeStruct::DataTypeStruct(const DataTypes& elems_, const 
Strings& names_)
         : elems(elems_), names(names_), have_explicit_names(true) {
     size_t size = elems.size();
     if (names.size() != size) {
-        LOG(FATAL) << "Wrong number of names passed to constructor of 
DataTypeStruct";
+        throw doris::Exception(ErrorCode::INTERNAL_ERROR,
+                               "Wrong number of names passed to constructor of 
DataTypeStruct");
         __builtin_unreachable();
     }
 
@@ -343,7 +344,8 @@ size_t DataTypeStruct::get_position_by_name(const String& 
name) const {
             return i;
         }
     }
-    LOG(FATAL) << "Struct doesn't have element with name '" + name + "'";
+    throw doris::Exception(ErrorCode::INTERNAL_ERROR,
+                           "Struct doesn't have element with name  " + name);
     __builtin_unreachable();
 }
 
diff --git a/be/src/vec/data_types/data_type_struct.h 
b/be/src/vec/data_types/data_type_struct.h
index 172e5ec3ff5..67e91886daa 100644
--- a/be/src/vec/data_types/data_type_struct.h
+++ b/be/src/vec/data_types/data_type_struct.h
@@ -96,7 +96,8 @@ public:
     Field get_default() const override;
 
     Field get_field(const TExprNode& node) const override {
-        LOG(FATAL) << "Unimplemented get_field for struct";
+        throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
+                               "Unimplemented get_field for struct");
         __builtin_unreachable();
     }
 
diff --git a/be/src/vec/data_types/data_type_time.h 
b/be/src/vec/data_types/data_type_time.h
index c7f5068b9f4..4f218347ebe 100644
--- a/be/src/vec/data_types/data_type_time.h
+++ b/be/src/vec/data_types/data_type_time.h
@@ -77,7 +77,7 @@ class DataTypeTimeV2 final : public 
DataTypeNumberBase<Float64> {
 public:
     DataTypeTimeV2(int scale = 0) : _scale(scale) {
         if (UNLIKELY(scale > 6)) {
-            LOG(FATAL) << fmt::format("Scale {} is out of bounds", scale);
+            throw doris::Exception(ErrorCode::INTERNAL_ERROR, "Scale {} is out 
of bounds", scale);
         }
         if (scale == -1) {
             _scale = 0;
diff --git a/be/src/vec/data_types/data_type_time_v2.h 
b/be/src/vec/data_types/data_type_time_v2.h
index f15a06303c6..86ce7836c56 100644
--- a/be/src/vec/data_types/data_type_time_v2.h
+++ b/be/src/vec/data_types/data_type_time_v2.h
@@ -107,7 +107,7 @@ public:
 
     DataTypeDateTimeV2(UInt32 scale = 0) : _scale(scale) {
         if (UNLIKELY(scale > 6)) {
-            LOG(FATAL) << fmt::format("Scale {} is out of bounds", scale);
+            throw doris::Exception(ErrorCode::INTERNAL_ERROR, "Scale {} is out 
of bounds", scale);
         }
     }
 
diff --git a/be/src/vec/data_types/serde/data_type_decimal_serde.h 
b/be/src/vec/data_types/serde/data_type_decimal_serde.h
index 484c6686bc5..dd31c3321af 100644
--- a/be/src/vec/data_types/serde/data_type_decimal_serde.h
+++ b/be/src/vec/data_types/serde/data_type_decimal_serde.h
@@ -65,7 +65,8 @@ public:
         if constexpr (std::is_same_v<TypeId<T>, TypeId<Decimal256>>) {
             return TYPE_DECIMAL256;
         }
-        LOG(FATAL) << "__builtin_unreachable";
+        throw doris::Exception(ErrorCode::INTERNAL_ERROR,
+                               "get_primitive_type __builtin_unreachable");
         __builtin_unreachable();
     }
 
diff --git a/be/src/vec/data_types/serde/data_type_number_serde.h 
b/be/src/vec/data_types/serde/data_type_number_serde.h
index 18ba2fb26c7..69fdd6e045e 100644
--- a/be/src/vec/data_types/serde/data_type_number_serde.h
+++ b/be/src/vec/data_types/serde/data_type_number_serde.h
@@ -319,7 +319,8 @@ Status DataTypeNumberSerDe<T>::write_one_cell_to_json(const 
IColumn& column,
     } else if constexpr (std::is_same_v<T, double>) {
         result.SetDouble(data[row_num]);
     } else {
-        LOG(FATAL) << "unknown column type " << column.get_name() << " for 
writing to jsonb";
+        throw doris::Exception(ErrorCode::INTERNAL_ERROR,
+                               "unknown column type {} for writing to jsonb " 
+ column.get_name());
         __builtin_unreachable();
     }
     return Status::OK();
diff --git a/be/src/vec/functions/array/function_array_cum_sum.cpp 
b/be/src/vec/functions/array/function_array_cum_sum.cpp
index 08281b31ef8..24750b55f6c 100644
--- a/be/src/vec/functions/array/function_array_cum_sum.cpp
+++ b/be/src/vec/functions/array/function_array_cum_sum.cpp
@@ -18,6 +18,7 @@
 // 
https://github.com/ClickHouse/ClickHouse/blob/master/src/Functions/array/arrayCumSum.cpp
 // and modified by Doris
 
+#include "common/status.h"
 #include "vec/columns/column.h"
 #include "vec/columns/column_array.h"
 #include "vec/core/types.h"
@@ -86,9 +87,10 @@ public:
         if (return_type) {
             return std::make_shared<DataTypeArray>(make_nullable(return_type));
         } else {
-            LOG(FATAL) << "Function of " << name
-                       << " return type get wrong: and input argument is: "
-                       << arguments[0]->get_name();
+            throw doris::Exception(
+                    ErrorCode::INVALID_ARGUMENT,
+                    "Function of {}, return type get wrong: and input argument 
is: {}", name,
+                    arguments[0]->get_name());
         }
 
         return nullptr;
diff --git a/be/src/vec/functions/array/function_array_difference.h 
b/be/src/vec/functions/array/function_array_difference.h
index b078396a91f..9eca677f033 100644
--- a/be/src/vec/functions/array/function_array_difference.h
+++ b/be/src/vec/functions/array/function_array_difference.h
@@ -96,9 +96,10 @@ public:
             return std::make_shared<DataTypeArray>(is_nullable ? 
make_nullable(return_type)
                                                                : return_type);
         } else {
-            LOG(FATAL) << "Function of " << name
-                       << " return type get wrong: and input argument is: "
-                       << arguments[0]->get_name();
+            throw doris::Exception(
+                    ErrorCode::INVALID_ARGUMENT,
+                    "Function of {}, return type get wrong: and input argument 
is: {}", name,
+                    arguments[0]->get_name());
         }
     }
 
diff --git a/be/src/vec/functions/array/function_array_enumerate.cpp 
b/be/src/vec/functions/array/function_array_enumerate.cpp
index be71636d044..0ce927db897 100644
--- a/be/src/vec/functions/array/function_array_enumerate.cpp
+++ b/be/src/vec/functions/array/function_array_enumerate.cpp
@@ -61,9 +61,10 @@ public:
         const DataTypeArray* array_type =
                 
check_and_get_data_type<DataTypeArray>(remove_nullable(arguments[0]).get());
         if (!array_type) {
-            LOG(FATAL) << "First argument for function " + get_name() +
-                                  " must be an array but it has type " + 
arguments[0]->get_name() +
-                                  ".";
+            throw doris::Exception(
+                    ErrorCode::INVALID_ARGUMENT,
+                    "First argument for function {} .must be an array but it 
type is {}",
+                    get_name(), arguments[0]->get_name());
         }
 
         auto nested_type = assert_cast<const 
DataTypeArray&>(*array_type).get_nested_type();
diff --git a/be/src/vec/functions/array/function_array_enumerate_uniq.cpp 
b/be/src/vec/functions/array/function_array_enumerate_uniq.cpp
index d0936130573..4c073386e4d 100644
--- a/be/src/vec/functions/array/function_array_enumerate_uniq.cpp
+++ b/be/src/vec/functions/array/function_array_enumerate_uniq.cpp
@@ -79,7 +79,9 @@ public:
 
     DataTypePtr get_return_type_impl(const DataTypes& arguments) const 
override {
         if (arguments.empty()) {
-            LOG(FATAL) << "Incorrect number of arguments for 
array_enumerate_uniq function";
+            throw doris::Exception(
+                    ErrorCode::INVALID_ARGUMENT,
+                    "Incorrect number of arguments for array_enumerate_uniq 
function");
             __builtin_unreachable();
         }
         bool is_nested_nullable = false;
@@ -87,10 +89,10 @@ public:
             const DataTypeArray* array_type =
                     
check_and_get_data_type<DataTypeArray>(remove_nullable(arguments[i]).get());
             if (!array_type) {
-                LOG(FATAL) << "The " << i
-                           << "-th argument for function " + get_name() +
-                                      " must be an array but it has type " +
-                                      arguments[i]->get_name() + ".";
+                throw doris::Exception(
+                        ErrorCode::INVALID_ARGUMENT,
+                        "The {} -th argument for function: {} .must be an 
array but it type is {}",
+                        i, get_name(), arguments[i]->get_name());
             }
             is_nested_nullable = is_nested_nullable || 
array_type->get_nested_type()->is_nullable();
         }
diff --git a/be/src/vec/functions/function.h b/be/src/vec/functions/function.h
index f6483c113f5..f618cc9a1b0 100644
--- a/be/src/vec/functions/function.h
+++ b/be/src/vec/functions/function.h
@@ -231,8 +231,9 @@ public:
     virtual Monotonicity get_monotonicity_for_range(const IDataType& /*type*/,
                                                     const Field& /*left*/,
                                                     const Field& /*right*/) 
const {
-        LOG(FATAL) << fmt::format("Function {} has no information about its 
monotonicity.",
-                                  get_name());
+        throw doris::Exception(ErrorCode::INTERNAL_ERROR,
+                               "Function {} has no information about its 
monotonicity.",
+                               get_name());
         return Monotonicity {};
     }
 
@@ -330,13 +331,15 @@ protected:
     // whether to wrap in nullable type will be automatically decided.
     virtual DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& 
arguments) const {
         DataTypes data_types(arguments.size());
-        for (size_t i = 0; i < arguments.size(); ++i) data_types[i] = 
arguments[i].type;
-
+        for (size_t i = 0; i < arguments.size(); ++i) {
+            data_types[i] = arguments[i].type;
+        }
         return get_return_type_impl(data_types);
     }
 
     virtual DataTypePtr get_return_type_impl(const DataTypes& /*arguments*/) 
const {
-        LOG(FATAL) << fmt::format("get_return_type is not implemented for {}", 
get_name());
+        throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
+                               "get_return_type is not implemented for {}", 
get_name());
         return nullptr;
     }
 
@@ -411,7 +414,8 @@ public:
                                              const Block& /*sample_block*/,
                                              const ColumnNumbers& 
/*arguments*/,
                                              size_t /*result*/) const final {
-        LOG(FATAL) << "prepare is not implemented for IFunction";
+        throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
+                               "prepare is not implemented for IFunction {}", 
get_name());
         __builtin_unreachable();
     }
 
@@ -420,19 +424,23 @@ public:
     }
 
     [[noreturn]] const DataTypes& get_argument_types() const final {
-        LOG(FATAL) << "get_argument_types is not implemented for IFunction";
+        throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
+                               "get_argument_types is not implemented for 
IFunction {}",
+                               get_name());
         __builtin_unreachable();
     }
 
     [[noreturn]] const DataTypePtr& get_return_type() const final {
-        LOG(FATAL) << "get_return_type is not implemented for IFunction";
+        throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
+                               "get_return_type is not implemented for 
IFunction {}", get_name());
         __builtin_unreachable();
     }
 
 protected:
     FunctionBasePtr build_impl(const ColumnsWithTypeAndName& /*arguments*/,
                                const DataTypePtr& /*return_type*/) const final 
{
-        LOG(FATAL) << "build_impl is not implemented for IFunction";
+        throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
+                               "build_impl is not implemented for IFunction 
{}", get_name());
         __builtin_unreachable();
         return {};
     }
diff --git a/be/src/vec/functions/function_binary_arithmetic.h 
b/be/src/vec/functions/function_binary_arithmetic.h
index 53d8141bc9e..d69b00043a1 100644
--- a/be/src/vec/functions/function_binary_arithmetic.h
+++ b/be/src/vec/functions/function_binary_arithmetic.h
@@ -419,7 +419,8 @@ public:
 
         if constexpr (check_overflow && !is_to_null_type &&
                       ((!OpTraits::is_multiply && !OpTraits::is_plus_minus))) {
-            LOG(FATAL) << "Invalid function type!";
+            throw doris::Exception(ErrorCode::INTERNAL_ERROR,
+                                   "adapt_decimal_constant_constant Invalid 
function type!");
             return column_result;
         } else if constexpr (is_to_null_type) {
             auto null_map = ColumnUInt8::create(1, 0);
@@ -449,7 +450,8 @@ public:
 
         if constexpr (check_overflow && !is_to_null_type &&
                       ((!OpTraits::is_multiply && !OpTraits::is_plus_minus))) {
-            LOG(FATAL) << "Invalid function type!";
+            throw doris::Exception(ErrorCode::INTERNAL_ERROR,
+                                   "adapt_decimal_vector_constant Invalid 
function type!");
             return column_result;
         } else if constexpr (is_to_null_type) {
             auto null_map = ColumnUInt8::create(column_left->size(), 0);
@@ -479,7 +481,8 @@ public:
 
         if constexpr (check_overflow && !is_to_null_type &&
                       ((!OpTraits::is_multiply && !OpTraits::is_plus_minus))) {
-            LOG(FATAL) << "Invalid function type!";
+            throw doris::Exception(ErrorCode::INTERNAL_ERROR,
+                                   "adapt_decimal_constant_vector Invalid 
function type!");
             return column_result;
         } else if constexpr (is_to_null_type) {
             auto null_map = ColumnUInt8::create(column_right->size(), 0);
@@ -511,7 +514,8 @@ public:
 
         if constexpr (check_overflow && !is_to_null_type &&
                       ((!OpTraits::is_multiply && !OpTraits::is_plus_minus))) {
-            LOG(FATAL) << "Invalid function type!";
+            throw doris::Exception(ErrorCode::INTERNAL_ERROR,
+                                   "adapt_decimal_vector_vector Invalid 
function type!");
             return column_result;
         } else if constexpr (is_to_null_type) {
             // function divide, modulo and pmod
diff --git a/be/src/vec/functions/function_cast.h 
b/be/src/vec/functions/function_cast.h
index 54f6a834a9e..68b1eb85f26 100644
--- a/be/src/vec/functions/function_cast.h
+++ b/be/src/vec/functions/function_cast.h
@@ -117,8 +117,8 @@ inline UInt32 extract_to_decimal_scale(const 
ColumnWithTypeAndName& named_column
               check_and_get_data_type<DataTypeUInt16>(arg_type) ||
               check_and_get_data_type<DataTypeUInt8>(arg_type);
     if (!ok) {
-        LOG(FATAL) << fmt::format("Illegal type of toDecimal() scale {}",
-                                  named_column.type->get_name());
+        throw doris::Exception(ErrorCode::INVALID_ARGUMENT, "Illegal type of 
toDecimal() scale {}",
+                               named_column.type->get_name());
     }
 
     Field field;
@@ -1607,8 +1607,10 @@ public:
     DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) 
const override {
         DataTypePtr res;
         if constexpr (IsDataTypeDecimal<ToDataType>) {
-            LOG(FATAL) << "Someting wrong with toDecimalNNOrZero() or 
toDecimalNNOrNull()";
-
+            auto error_type = std::make_shared<ToDataType>();
+            throw doris::Exception(ErrorCode::INVALID_ARGUMENT,
+                                   "something wrong type in function {}.", 
get_name(),
+                                   error_type->get_name());
         } else {
             res = std::make_shared<ToDataType>();
         }
diff --git a/be/src/vec/functions/function_date_or_datetime_computation.h 
b/be/src/vec/functions/function_date_or_datetime_computation.h
index 92a70bc8c92..567209419ff 100644
--- a/be/src/vec/functions/function_date_or_datetime_computation.h
+++ b/be/src/vec/functions/function_date_or_datetime_computation.h
@@ -712,16 +712,17 @@ public:
 
     DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) 
const override {
         if (arguments.size() != 2 && arguments.size() != 3) {
-            LOG(FATAL) << fmt::format(
-                    "Number of arguments for function {} doesn't match: passed 
{} , should be 2 or "
-                    "3",
-                    get_name(), arguments.size());
+            throw doris::Exception(ErrorCode::INVALID_ARGUMENT,
+                                   "Number of arguments for function {} 
doesn't match: passed {} , "
+                                   "should be 2 or 3",
+                                   get_name(), arguments.size());
         }
 
         if (arguments.size() == 2) {
             if (!is_date_or_datetime(remove_nullable(arguments[0].type)) &&
                 
!is_date_v2_or_datetime_v2(remove_nullable(arguments[0].type))) {
-                LOG(FATAL) << fmt::format(
+                throw doris::Exception(
+                        ErrorCode::INVALID_ARGUMENT,
                         "Illegal type {} of argument of function {}. Should be 
a date or a date "
                         "with time",
                         arguments[0].type->get_name(), get_name());
@@ -730,7 +731,8 @@ public:
             if 
(!WhichDataType(remove_nullable(arguments[0].type)).is_date_time() ||
                 
!WhichDataType(remove_nullable(arguments[0].type)).is_date_time_v2() ||
                 
!WhichDataType(remove_nullable(arguments[2].type)).is_string()) {
-                LOG(FATAL) << fmt::format(
+                throw doris::Exception(
+                        ErrorCode::INVALID_ARGUMENT,
                         "Function {} supports 2 or 3 arguments. The 1st 
argument must be of type "
                         "Date or DateTime. The 2nd argument must be number. 
The 3rd argument "
                         "(optional) must be a constant string with timezone 
name. The timezone "
diff --git a/be/src/vec/functions/function_date_or_datetime_to_something.h 
b/be/src/vec/functions/function_date_or_datetime_to_something.h
index e711ad7b005..4bea968a62c 100644
--- a/be/src/vec/functions/function_date_or_datetime_to_something.h
+++ b/be/src/vec/functions/function_date_or_datetime_to_something.h
@@ -51,21 +51,22 @@ public:
         if (arguments.size() == 1) {
             if (!is_date_or_datetime(remove_nullable(arguments[0].type)) &&
                 
!is_date_v2_or_datetime_v2(remove_nullable(arguments[0].type))) {
-                LOG(FATAL) << fmt::format(
-                        "Illegal type {} of argument of function {}. Should be 
a date or a date "
-                        "with time",
-                        arguments[0].type->get_name(), get_name());
+                throw doris::Exception(ErrorCode::INVALID_ARGUMENT,
+                                       "Illegal type {} of argument of 
function {}. Should be a "
+                                       "date or a date with time",
+                                       arguments[0].type->get_name(), 
get_name());
             }
         } else if (arguments.size() == 2) {
             if (!is_date_or_datetime(remove_nullable(arguments[0].type)) &&
                 
!is_date_v2_or_datetime_v2(remove_nullable(arguments[0].type))) {
-                LOG(FATAL) << fmt::format(
-                        "Illegal type {} of argument of function {}. Should be 
a date or a date "
-                        "with time",
-                        arguments[0].type->get_name(), get_name());
+                throw doris::Exception(ErrorCode::INVALID_ARGUMENT,
+                                       "Illegal type {} of argument of 
function {}. Should be a "
+                                       "date or a date with time",
+                                       arguments[0].type->get_name(), 
get_name());
             }
             if (!is_string(remove_nullable(arguments[1].type))) {
-                LOG(FATAL) << fmt::format(
+                throw doris::Exception(
+                        ErrorCode::INVALID_ARGUMENT,
                         "Function {} supports 1 or 2 arguments. The 1st 
argument must be of type "
                         "Date or DateTime. The 2nd argument (optional) must be 
a constant string "
                         "with timezone name",
@@ -73,16 +74,17 @@ public:
             }
             if (is_date(remove_nullable(arguments[0].type)) &&
                 std::is_same_v<ToDataType, DataTypeDate>) {
-                LOG(FATAL) << fmt::format(
+                throw doris::Exception(
+                        ErrorCode::INVALID_ARGUMENT,
                         "The timezone argument of function {} is allowed only 
when the 1st "
                         "argument has the type DateTime",
                         get_name());
             }
         } else {
-            LOG(FATAL) << fmt::format(
-                    "Number of arguments for function {} doesn't match: passed 
{}, should be 1 or "
-                    "2",
-                    get_name(), arguments.size());
+            throw doris::Exception(ErrorCode::INVALID_ARGUMENT,
+                                   "Number of arguments for function {} 
doesn't match: passed {}, "
+                                   "should be 1 or 2",
+                                   get_name(), arguments.size());
         }
 
         RETURN_REAL_TYPE_FOR_DATEV2_FUNCTION(ToDataType);
diff --git a/be/src/vec/functions/function_helpers.cpp 
b/be/src/vec/functions/function_helpers.cpp
index c6202e2b088..22dbd9073d1 100644
--- a/be/src/vec/functions/function_helpers.cpp
+++ b/be/src/vec/functions/function_helpers.cpp
@@ -30,6 +30,7 @@
 #include <vector>
 
 #include "common/consts.h"
+#include "common/status.h"
 #include "util/string_util.h"
 #include "vec/columns/column_nullable.h"
 #include "vec/columns/column_string.h"
@@ -92,8 +93,9 @@ std::tuple<Block, ColumnNumbers> 
create_block_with_nested_columns(
                     res.insert({ColumnConst::create(nested_col, 
col.column->size()), nested_type,
                                 col.name});
                 } else {
-                    LOG(FATAL) << "Illegal column= " << col.column->get_name()
-                               << " for DataTypeNullable";
+                    throw doris::Exception(
+                            ErrorCode::INTERNAL_ERROR,
+                            "Illegal column= {},  for DataTypeNullable" + 
col.column->get_name());
                 }
             } else {
                 res.insert(col);
@@ -130,14 +132,16 @@ void validate_argument_type(const IFunction& func, const 
DataTypes& arguments,
                             size_t argument_index, bool 
(*validator_func)(const IDataType&),
                             const char* expected_type_description) {
     if (arguments.size() <= argument_index) {
-        LOG(FATAL) << "Incorrect number of arguments of function " << 
func.get_name();
+        throw doris::Exception(ErrorCode::INVALID_ARGUMENT,
+                               "Incorrect number of arguments of function {}" 
+ func.get_name());
     }
 
     const auto& argument = arguments[argument_index];
     if (validator_func(*argument) == false) {
-        LOG(FATAL) << fmt::format("Illegal type {} of {} argument of function 
{} expected {}",
-                                  argument->get_name(), argument_index, 
func.get_name(),
-                                  expected_type_description);
+        throw doris::Exception(ErrorCode::INVALID_ARGUMENT,
+                               "Illegal type {} of {} argument of function {} 
expected {}",
+                               argument->get_name(), argument_index, 
func.get_name(),
+                               expected_type_description);
     }
 }
 
diff --git a/be/src/vec/functions/function_jsonb.cpp 
b/be/src/vec/functions/function_jsonb.cpp
index ee0bad3e992..c262a6ce1ad 100644
--- a/be/src/vec/functions/function_jsonb.cpp
+++ b/be/src/vec/functions/function_jsonb.cpp
@@ -1099,7 +1099,8 @@ private:
                 res[i] = 0;
             }
         } else {
-            LOG(FATAL) << "unexpected type ";
+            throw doris::Exception(ErrorCode::INVALID_ARGUMENT,
+                                   "unexpected type in JsonbExtractImpl");
             __builtin_unreachable();
         }
     }
diff --git a/be/src/vec/functions/function_string.cpp 
b/be/src/vec/functions/function_string.cpp
index 90a053b07a5..f2983e01684 100644
--- a/be/src/vec/functions/function_string.cpp
+++ b/be/src/vec/functions/function_string.cpp
@@ -768,8 +768,9 @@ public:
 
     DataTypePtr get_return_type_impl(const DataTypes& arguments) const 
override {
         if (!is_string_or_fixed_string(arguments[0])) {
-            LOG(FATAL) << fmt::format("Illegal type {} of argument of function 
{}",
-                                      arguments[0]->get_name(), get_name());
+            throw doris::Exception(ErrorCode::INVALID_ARGUMENT,
+                                   "Illegal type {} of argument of function 
{}",
+                                   arguments[0]->get_name(), get_name());
         }
         return arguments[0];
     }
diff --git a/be/src/vec/functions/function_string_to_string.h 
b/be/src/vec/functions/function_string_to_string.h
index fdc413e20cb..3dac2cf94fd 100644
--- a/be/src/vec/functions/function_string_to_string.h
+++ b/be/src/vec/functions/function_string_to_string.h
@@ -44,8 +44,9 @@ public:
 
     DataTypePtr get_return_type_impl(const DataTypes& arguments) const 
override {
         if (!is_string_or_fixed_string(arguments[0])) {
-            LOG(FATAL) << fmt::format("Illegal type {} of argument of function 
{}",
-                                      arguments[0]->get_name(), get_name());
+            throw doris::Exception(ErrorCode::INVALID_ARGUMENT,
+                                   "Illegal type {} of argument of function 
{}",
+                                   arguments[0]->get_name(), get_name());
         }
 
         return arguments[0];
diff --git a/be/src/vec/functions/function_unary_arithmetic.h 
b/be/src/vec/functions/function_unary_arithmetic.h
index 7159067a31c..91e33a7b9d4 100644
--- a/be/src/vec/functions/function_unary_arithmetic.h
+++ b/be/src/vec/functions/function_unary_arithmetic.h
@@ -99,8 +99,9 @@ public:
             return true;
         });
         if (!valid) {
-            LOG(FATAL) << fmt::format("Illegal type {} of argument of function 
{}",
-                                      arguments[0]->get_name(), get_name());
+            throw doris::Exception(ErrorCode::INVALID_ARGUMENT,
+                                   "Illegal type {} of argument of function 
{}",
+                                   arguments[0]->get_name(), get_name());
         }
         return result;
     }
diff --git a/be/src/vec/functions/function_variadic_arguments.h 
b/be/src/vec/functions/function_variadic_arguments.h
index dab685f10ae..c8148fc90d0 100644
--- a/be/src/vec/functions/function_variadic_arguments.h
+++ b/be/src/vec/functions/function_variadic_arguments.h
@@ -18,6 +18,7 @@
 #pragma once
 #include <utility>
 
+#include "common/status.h"
 #include "vec/columns/column_string.h"
 #include "vec/columns/column_vector.h"
 #include "vec/data_types/data_type.h"
@@ -42,11 +43,14 @@ public:
         if constexpr (IsDataTypeDecimalV2<ToDataType>) {
             res = create_decimal(27, 9, true);
             if (!res) {
-                LOG(FATAL) << "Someting wrong with toDecimalNNOrZero() or 
toDecimalNNOrNull()";
+                throw doris::Exception(ErrorCode::INVALID_ARGUMENT,
+                                       "Something wrong with create_decimal in 
function {}",
+                                       get_name());
                 __builtin_unreachable();
             }
-        } else
+        } else {
             res = std::make_shared<ToDataType>();
+        }
         return res;
     }
 
diff --git a/be/src/vec/functions/functions_comparison.h 
b/be/src/vec/functions/functions_comparison.h
index 90e132cdd53..bb1666ab864 100644
--- a/be/src/vec/functions/functions_comparison.h
+++ b/be/src/vec/functions/functions_comparison.h
@@ -347,11 +347,12 @@ private:
                 execute_num_right_type<T0, Int128>(block, result, col_left, 
col_right_untyped) ||
                 execute_num_right_type<T0, IPv6>(block, result, col_left, 
col_right_untyped) ||
                 execute_num_right_type<T0, Float32>(block, result, col_left, 
col_right_untyped) ||
-                execute_num_right_type<T0, Float64>(block, result, col_left, 
col_right_untyped))
+                execute_num_right_type<T0, Float64>(block, result, col_left, 
col_right_untyped)) {
                 return true;
-            else {
-                LOG(FATAL) << "Illegal column " << 
col_right_untyped->get_name()
-                           << " of second argument of function " << get_name();
+            } else {
+                throw doris::Exception(ErrorCode::INVALID_ARGUMENT,
+                                       "Illegal column ({}) of second argument 
of function {}",
+                                       col_right_untyped->get_name(), 
get_name());
             }
 
         } else if (auto col_left_const =
@@ -379,11 +380,12 @@ private:
                 execute_num_const_right_type<T0, Float32>(block, result, 
col_left_const,
                                                           col_right_untyped) ||
                 execute_num_const_right_type<T0, Float64>(block, result, 
col_left_const,
-                                                          col_right_untyped))
+                                                          col_right_untyped)) {
                 return true;
-            else {
-                LOG(FATAL) << "Illegal column " << 
col_right_untyped->get_name()
-                           << " of second argument of function " << get_name();
+            } else {
+                throw doris::Exception(ErrorCode::INVALID_ARGUMENT,
+                                       "Illegal column ({}) f second argument 
of function {}",
+                                       col_right_untyped->get_name(), 
get_name());
             }
         }
 
diff --git a/be/src/vec/functions/functions_logical.cpp 
b/be/src/vec/functions/functions_logical.cpp
index c0b8d62ec25..f7c1192f331 100644
--- a/be/src/vec/functions/functions_logical.cpp
+++ b/be/src/vec/functions/functions_logical.cpp
@@ -26,6 +26,7 @@
 #include <vector>
 
 #include "common/compiler_util.h" // IWYU pragma: keep
+#include "common/status.h"
 #include "gutil/integral_types.h"
 #include "vec/aggregate_functions/aggregate_function.h"
 #include "vec/columns/column.h"
@@ -168,7 +169,8 @@ template <typename Impl, typename Name>
 DataTypePtr FunctionAnyArityLogical<Impl, Name>::get_return_type_impl(
         const DataTypes& arguments) const {
     if (arguments.size() < 2) {
-        LOG(FATAL) << fmt::format(
+        throw doris::Exception(
+                ErrorCode::INVALID_ARGUMENT,
                 "Number of arguments for function \"{}\" should be at least 2: 
passed {}",
                 get_name(), arguments.size());
     }
@@ -189,8 +191,9 @@ DataTypePtr FunctionAnyArityLogical<Impl, 
Name>::get_return_type_impl(
 
         if (!(is_native_number(arg_type) || 
(Impl::special_implementation_for_nulls() &&
                                              
is_native_number(remove_nullable(arg_type))))) {
-            LOG(FATAL) << fmt::format("Illegal type ({}) of {} argument of 
function {}",
-                                      arg_type->get_name(), i + 1, get_name());
+            throw doris::Exception(ErrorCode::INVALID_ARGUMENT,
+                                   "Illegal type ({}) of {} argument of 
function {}",
+                                   arg_type->get_name(), i + 1, get_name());
         }
     }
 
@@ -231,8 +234,9 @@ template <template <typename> class Impl, typename Name>
 DataTypePtr FunctionUnaryLogical<Impl, Name>::get_return_type_impl(
         const DataTypes& arguments) const {
     if (!is_native_number(arguments[0])) {
-        LOG(FATAL) << fmt::format("Illegal type ({}) of argument of function 
{}",
-                                  arguments[0]->get_name(), get_name());
+        throw doris::Exception(ErrorCode::INVALID_ARGUMENT,
+                               "Illegal type ({}) of argument of function {}",
+                               arguments[0]->get_name(), get_name());
     }
 
     return std::make_shared<DataTypeUInt8>();
@@ -260,9 +264,9 @@ Status FunctionUnaryLogical<Impl, 
Name>::execute_impl(FunctionContext* context,
                                                       const ColumnNumbers& 
arguments, size_t result,
                                                       size_t 
/*input_rows_count*/) const {
     if (!functionUnaryExecuteType<Impl, UInt8>(block, arguments, result)) {
-        LOG(FATAL) << fmt::format("Illegal column {} of argument of function 
{}",
-                                  
block.get_by_position(arguments[0]).column->get_name(),
-                                  get_name());
+        throw doris::Exception(ErrorCode::INVALID_ARGUMENT,
+                               "Illegal column {} of argument of function {}",
+                               
block.get_by_position(arguments[0]).column->get_name(), get_name());
     }
 
     return Status::OK();
diff --git a/be/src/vec/functions/if.cpp b/be/src/vec/functions/if.cpp
index 14233f29725..102d1b63f10 100644
--- a/be/src/vec/functions/if.cpp
+++ b/be/src/vec/functions/if.cpp
@@ -118,7 +118,8 @@ template <typename A, typename B>
 struct NumIfImpl<A, B, NumberTraits::Error> {
 private:
     [[noreturn]] static void throw_error() {
-        LOG(FATAL) << "Internal logic error: invalid types of arguments 2 and 
3 of if";
+        throw doris::Exception(ErrorCode::INTERNAL_ERROR,
+                               "Internal logic error: invalid types of 
arguments 2 and 3 of if");
         __builtin_unreachable();
     }
 
diff --git a/be/src/vec/functions/round.h b/be/src/vec/functions/round.h
index 5d0b0f05159..dbf4f95037c 100644
--- a/be/src/vec/functions/round.h
+++ b/be/src/vec/functions/round.h
@@ -124,7 +124,8 @@ struct IntegerRoundingComputation {
             return target_scale > 1 ? x * target_scale : x;
         }
         }
-        LOG(FATAL) << "__builtin_unreachable";
+        throw doris::Exception(ErrorCode::INTERNAL_ERROR,
+                               "IntegerRoundingComputation 
__builtin_unreachable ", rounding_mode);
         __builtin_unreachable();
     }
 
@@ -136,7 +137,8 @@ struct IntegerRoundingComputation {
         case ScaleMode::Negative:
             return compute_impl(x, scale, target_scale);
         }
-        LOG(FATAL) << "__builtin_unreachable";
+        throw doris::Exception(ErrorCode::INTERNAL_ERROR,
+                               "IntegerRoundingComputation 
__builtin_unreachable ", scale_mode);
         __builtin_unreachable();
     }
 
@@ -224,8 +226,7 @@ inline float roundWithMode(float x, RoundingMode mode) {
     case RoundingMode::Trunc:
         return truncf(x);
     }
-
-    LOG(FATAL) << "__builtin_unreachable";
+    throw doris::Exception(ErrorCode::INTERNAL_ERROR, "roundWithMode 
__builtin_unreachable ", mode);
     __builtin_unreachable();
 }
 
@@ -246,8 +247,7 @@ inline double roundWithMode(double x, RoundingMode mode) {
     case RoundingMode::Trunc:
         return trunc(x);
     }
-
-    LOG(FATAL) << "__builtin_unreachable";
+    throw doris::Exception(ErrorCode::INTERNAL_ERROR, "roundWithMode 
__builtin_unreachable ", mode);
     __builtin_unreachable();
 }
 
@@ -416,7 +416,8 @@ public:
         case 10000000000000000000ULL:
             return applyImpl<10000000000000000000ULL>(in, out);
         default:
-            LOG(FATAL) << "__builtin_unreachable";
+            throw doris::Exception(ErrorCode::INTERNAL_ERROR,
+                                   "IntegerRoundingImpl __builtin_unreachable 
", scale);
             __builtin_unreachable();
         }
     }
@@ -500,7 +501,10 @@ struct Dispatcher {
 
             return col_res;
         } else {
-            LOG(FATAL) << "__builtin_unreachable";
+            auto error_type = std::make_shared<T>();
+            throw doris::Exception(ErrorCode::INTERNAL_ERROR,
+                                   "Dispatcher apply_vec_const 
__builtin_unreachable {}",
+                                   error_type->get_name());
             __builtin_unreachable();
             return nullptr;
         }
@@ -577,7 +581,10 @@ struct Dispatcher {
 
             return col_res;
         } else {
-            LOG(FATAL) << "__builtin_unreachable";
+            auto error_type = std::make_shared<T>();
+            throw doris::Exception(ErrorCode::INTERNAL_ERROR,
+                                   "Dispatcher apply_vec_vec 
__builtin_unreachable {}",
+                                   error_type->get_name());
             __builtin_unreachable();
             return nullptr;
         }
@@ -659,7 +666,10 @@ struct Dispatcher {
 
             return col_res;
         } else {
-            LOG(FATAL) << "__builtin_unreachable";
+            auto error_type = std::make_shared<T>();
+            throw doris::Exception(ErrorCode::INTERNAL_ERROR,
+                                   "Dispatcher apply_const_vec 
__builtin_unreachable {}",
+                                   error_type->get_name());
             __builtin_unreachable();
             return nullptr;
         }
@@ -684,8 +694,10 @@ public:
     /// Get result types by argument types. If the function does not apply to 
these arguments, throw an exception.
     DataTypePtr get_return_type_impl(const DataTypes& arguments) const 
override {
         if ((arguments.empty()) || (arguments.size() > 2)) {
-            LOG(FATAL) << "Number of arguments for function " + get_name() +
-                                  " doesn't match: should be 1 or 2. ";
+            throw doris::Exception(
+                    ErrorCode::INVALID_ARGUMENT,
+                    "Number of arguments for function {}, doesn't match: 
should be 1 or 2. ",
+                    get_name());
         }
 
         return arguments[0];
diff --git a/be/src/vec/json/json_parser.cpp b/be/src/vec/json/json_parser.cpp
index 515cd447573..069f985c6fd 100644
--- a/be/src/vec/json/json_parser.cpp
+++ b/be/src/vec/json/json_parser.cpp
@@ -28,6 +28,7 @@
 #include <string_view>
 
 #include "common/config.h"
+#include "common/status.h"
 #include "vec/json/path_in_data.h"
 #include "vec/json/simd_json_parser.h"
 
@@ -252,8 +253,9 @@ void JSONDataParser<ParserImpl, 
parse_nested>::traverseArrayElement(const Elemen
                 if (current_nested_sizes.size() == ctx.current_size) {
                     current_nested_sizes.push_back(array_size);
                 } else if (array_size != current_nested_sizes.back()) {
-                    LOG(FATAL) << fmt::format("Array sizes mismatched ({} and 
{})", array_size,
-                                              current_nested_sizes.back());
+                    throw doris::Exception(ErrorCode::INTERNAL_ERROR,
+                                           "Array sizes mismatched ({} and 
{})", array_size,
+                                           current_nested_sizes.back());
                 }
             }
             path_array.push_back(std::move(values[i]));


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to