Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cherry-pick](branch-21) replace the LOG(FATAL) to throw Exception in query execute layer (#38144) #44183

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions be/src/vec/aggregate_functions/aggregate_function_min_max.h
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
}
Expand Down
8 changes: 5 additions & 3 deletions be/src/vec/aggregate_functions/aggregate_function_null.h
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
12 changes: 8 additions & 4 deletions be/src/vec/aggregate_functions/aggregate_function_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
12 changes: 7 additions & 5 deletions be/src/vec/aggregate_functions/factory_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 12 additions & 5 deletions be/src/vec/data_types/data_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -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;
}
}
Expand Down
3 changes: 2 additions & 1 deletion be/src/vec/data_types/data_type_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
3 changes: 2 additions & 1 deletion be/src/vec/data_types/data_type_bitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
3 changes: 2 additions & 1 deletion be/src/vec/data_types/data_type_decimal.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,8 @@ class DataTypeDecimal final : public IDataType {
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();
}

Expand Down
2 changes: 1 addition & 1 deletion be/src/vec/data_types/data_type_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
3 changes: 2 additions & 1 deletion be/src/vec/data_types/data_type_fixed_length_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
2 changes: 1 addition & 1 deletion be/src/vec/data_types/data_type_hll.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
2 changes: 1 addition & 1 deletion be/src/vec/data_types/data_type_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
4 changes: 2 additions & 2 deletions be/src/vec/data_types/data_type_nothing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
10 changes: 7 additions & 3 deletions be/src/vec/data_types/data_type_nothing.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand All @@ -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());
};
};

Expand Down
3 changes: 2 additions & 1 deletion be/src/vec/data_types/data_type_nullable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
6 changes: 5 additions & 1 deletion be/src/vec/data_types/data_type_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {};
}

Expand Down
4 changes: 3 additions & 1 deletion be/src/vec/data_types/data_type_quantilestate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
}

Expand Down
6 changes: 4 additions & 2 deletions be/src/vec/data_types/data_type_struct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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();
}

Expand Down
3 changes: 2 additions & 1 deletion be/src/vec/data_types/data_type_struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
2 changes: 1 addition & 1 deletion be/src/vec/data_types/data_type_time.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion be/src/vec/data_types/data_type_time_v2.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class DataTypeDateTimeV2 final : public DataTypeNumberBase<UInt64> {

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);
}
}

Expand Down
3 changes: 2 additions & 1 deletion be/src/vec/data_types/serde/data_type_decimal_serde.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ class DataTypeDecimalSerDe : public DataTypeSerDe {
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();
}

Expand Down
Loading
Loading