From a8f5e87944e04481865c37e930a687c05b3fe85d Mon Sep 17 00:00:00 2001 From: zhangstar333 <87313068+zhangstar333@users.noreply.github.com> Date: Tue, 23 Jul 2024 10:21:47 +0800 Subject: [PATCH] [improve](execution) replace the LOG(FATAL) to throw Exception in query execute layer (#38144) As the LOG(FATAL) will cause BE core dump, so change it to throw exception in Execute Engine Layer. ## Proposed changes Issue Number: close #xxx --- .../aggregate_function_distinct.cpp | 5 +-- .../aggregate_function_min_max.h | 8 ++--- .../aggregate_function_null.h | 8 +++-- .../aggregate_function_reader_first_last.h | 12 ++++--- .../aggregate_function_window.h | 12 ++++--- .../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 +- .../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 +++- .../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 +- .../serde/data_type_decimal_serde.h | 3 +- .../data_types/serde/data_type_number_serde.h | 3 +- .../array/function_array_cum_sum.cpp | 8 +++-- .../array/function_array_difference.h | 7 ++-- .../array/function_array_enumerate.cpp | 7 ++-- .../array/function_array_enumerate_uniq.cpp | 12 ++++--- be/src/vec/functions/function.h | 26 +++++++++----- .../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 +-- .../vec/functions/function_string_to_string.h | 5 +-- .../vec/functions/function_unary_arithmetic.h | 5 +-- .../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 51138fe8c42184..fce58b38688b28 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 @@ class AggregateFunctionCombinatorDistinct final : public IAggregateFunctionCombi 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 16d7278adcd9e5..3d5671645861dc 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 @@ class AggregateFunctionsSingleValue final 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 53cad4e3b15eab..b2fbe1b2e7faff 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 @@ class AggregateFunctionNullVariadicInline final 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 41ad71ad8b01c5..d11350a5b3a323 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 @@ class ReaderFunctionData final 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 2c290c5fd07dee..d293383feb6f45 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 @@ class WindowFunctionData final 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 0bbedce05ad75a..553f05c3665a5b 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 e1c12d429fffd5..046266a39cdde9 100644 --- a/be/src/vec/data_types/data_type.cpp +++ b/be/src/vec/data_types/data_type.cpp @@ -28,6 +28,7 @@ #include #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 7441538b839524..ae58efc0ca1b21 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 @@ class DataTypeArray final : public IDataType { 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 08b46161779550..14fc1128ff0d8d 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 @@ class DataTypeBitMap : public IDataType { 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 2acae5800d0421..d95750c9f25cbd 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 @@ class DataTypeDecimal final : public IDataType { template T scale_factor_for(const DataTypeDecimal& 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 9c40588ed31111..7d77684dbb40ab 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 28ba8fe0f31906..53893cc87aaa27 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 @@ class DataTypeFixedLengthObject final : public IDataType { 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 f3856baecfb327..ab7dc817800868 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 @@ class DataTypeHLL : public IDataType { 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 fab925cc6f47bd..e7cc87cddf70b1 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 @@ class DataTypeMap final : public IDataType { 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 bd0cb9ae04b6c4..9dc9b873d9aa35 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 71733d6d34c6f3..0e2a77957fb626 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 @@ class DataTypeNothing final : public IDataType { 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 @@ class DataTypeNothing final : public IDataType { 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 b10244c85221a7..e6963632427853 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 5fbd5492466b56..cc24200cd18826 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 #include +#include #include +#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 @@ class DataTypeObject : public IDataType { 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 c07e1eb3a42bf2..e706427c409471 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 #include +#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 @@ class DataTypeQuantileState : public IDataType { 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 8a28a0998ccdce..3cef6c9701a9e2 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 172e5ec3ff598e..67e91886daa0da 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 @@ class DataTypeStruct final : public IDataType { 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 c7f5068b9f4775..4f218347ebe83c 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 { 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 f15a06303c664e..86ce7836c56755 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 @@ class DataTypeDateTimeV2 final : public DataTypeNumberBase { 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 484c6686bc58f8..dd31c3321afcc9 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 @@ class DataTypeDecimalSerDe : public DataTypeSerDe { if constexpr (std::is_same_v, TypeId>) { 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 18ba2fb26c79b5..69fdd6e045e1f7 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::write_one_cell_to_json(const IColumn& column, } else if constexpr (std::is_same_v) { 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 08281b31ef8a3b..24750b55f6c8c2 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 @@ class FunctionArrayCumSum : public IFunction { if (return_type) { return std::make_shared(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 b078396a91fea3..9eca677f0336ce 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 @@ class FunctionArrayDifference : public IFunction { return std::make_shared(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 be71636d04495a..0ce927db897870 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 @@ class FunctionArrayEnumerate : public IFunction { const DataTypeArray* array_type = check_and_get_data_type(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(*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 d0936130573dc0..4c073386e4d60e 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 @@ class FunctionArrayEnumerateUniq : public IFunction { 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 @@ class FunctionArrayEnumerateUniq : public IFunction { const DataTypeArray* array_type = check_and_get_data_type(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 f6483c113f550a..f618cc9a1b0ffb 100644 --- a/be/src/vec/functions/function.h +++ b/be/src/vec/functions/function.h @@ -231,8 +231,9 @@ class IFunctionBase { 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 @@ class FunctionBuilderImpl : public IFunctionBuilder { // 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 @@ class IFunction : public std::enable_shared_from_this, 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 @@ class IFunction : public std::enable_shared_from_this, } [[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 53d8141bc9e11d..d69b00043a15ec 100644 --- a/be/src/vec/functions/function_binary_arithmetic.h +++ b/be/src/vec/functions/function_binary_arithmetic.h @@ -419,7 +419,8 @@ struct DecimalBinaryOperation { 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 @@ struct DecimalBinaryOperation { 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 @@ struct DecimalBinaryOperation { 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 @@ struct DecimalBinaryOperation { 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 54f6a834a9e1a1..68b1eb85f26f09 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(arg_type) || check_and_get_data_type(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 @@ class FunctionConvertFromString : public IFunction { DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override { DataTypePtr res; if constexpr (IsDataTypeDecimal) { - LOG(FATAL) << "Someting wrong with toDecimalNNOrZero() or toDecimalNNOrNull()"; - + auto error_type = std::make_shared(); + throw doris::Exception(ErrorCode::INVALID_ARGUMENT, + "something wrong type in function {}.", get_name(), + error_type->get_name()); } else { res = std::make_shared(); } 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 92a70bc8c92ec0..567209419ff896 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 @@ class FunctionDateOrDateTimeComputation : public IFunction { 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 @@ class FunctionDateOrDateTimeComputation : public IFunction { 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 e711ad7b0059b0..4bea968a62c53b 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 @@ class FunctionDateOrDateTimeToSomething : public IFunction { 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 @@ class FunctionDateOrDateTimeToSomething : public IFunction { } if (is_date(remove_nullable(arguments[0].type)) && std::is_same_v) { - 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 c6202e2b08846e..22dbd9073d1797 100644 --- a/be/src/vec/functions/function_helpers.cpp +++ b/be/src/vec/functions/function_helpers.cpp @@ -30,6 +30,7 @@ #include #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 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 ee0bad3e992d36..c262a6ce1ad4fd 100644 --- a/be/src/vec/functions/function_jsonb.cpp +++ b/be/src/vec/functions/function_jsonb.cpp @@ -1099,7 +1099,8 @@ struct JsonbExtractImpl { 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 90a053b07a534d..f2983e016840cd 100644 --- a/be/src/vec/functions/function_string.cpp +++ b/be/src/vec/functions/function_string.cpp @@ -768,8 +768,9 @@ class FunctionTrim : public IFunction { 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 fdc413e20cb2fb..3dac2cf94fd1a7 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 @@ class FunctionStringToString : public IFunction { 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 7159067a31cebd..91e33a7b9d45e2 100644 --- a/be/src/vec/functions/function_unary_arithmetic.h +++ b/be/src/vec/functions/function_unary_arithmetic.h @@ -99,8 +99,9 @@ class FunctionUnaryArithmetic : public IFunction { 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 dab685f10ae253..c8148fc90d078b 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 +#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 @@ class FunctionVariadicArgumentsBase : public IFunction { if constexpr (IsDataTypeDecimalV2) { 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(); + } return res; } diff --git a/be/src/vec/functions/functions_comparison.h b/be/src/vec/functions/functions_comparison.h index 90e132cdd53743..bb1666ab864070 100644 --- a/be/src/vec/functions/functions_comparison.h +++ b/be/src/vec/functions/functions_comparison.h @@ -347,11 +347,12 @@ class FunctionComparison : public IFunction { execute_num_right_type(block, result, col_left, col_right_untyped) || execute_num_right_type(block, result, col_left, col_right_untyped) || execute_num_right_type(block, result, col_left, col_right_untyped) || - execute_num_right_type(block, result, col_left, col_right_untyped)) + execute_num_right_type(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 @@ class FunctionComparison : public IFunction { execute_num_const_right_type(block, result, col_left_const, col_right_untyped) || execute_num_const_right_type(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 c0b8d62ec259ba..f7c1192f331c0f 100644 --- a/be/src/vec/functions/functions_logical.cpp +++ b/be/src/vec/functions/functions_logical.cpp @@ -26,6 +26,7 @@ #include #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 DataTypePtr FunctionAnyArityLogical::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::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