From ace2b45c377fb72338babf1415a96850458862b8 Mon Sep 17 00:00:00 2001 From: Jerry Hu Date: Tue, 12 Dec 2023 20:32:10 +0800 Subject: [PATCH] [fix](decimalv2) avoid crashing caused by decimalv2 arithmetic with check_overflow_for_decimal enabled (#28219) --- be/src/vec/functions/function_binary_arithmetic.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/be/src/vec/functions/function_binary_arithmetic.h b/be/src/vec/functions/function_binary_arithmetic.h index ab89c3f854..a58417b71e 100644 --- a/be/src/vec/functions/function_binary_arithmetic.h +++ b/be/src/vec/functions/function_binary_arithmetic.h @@ -961,6 +961,8 @@ public: } bool check_overflow_for_decimal = context->check_overflow_for_decimal(); + auto status = Status::RuntimeError("{}'s arguments do not match the expected data types", + get_name()); bool valid = cast_both_types( left_generic, right_generic, result_generic, [&](const auto& left, const auto& right, const auto& res) { @@ -978,6 +980,13 @@ public: (IsDataTypeDecimal || IsDataTypeDecimal))) { if (check_overflow_for_decimal) { + if constexpr ((IsDecimalV2 || + IsDecimalV2)&&!is_to_null_type) { + status = Status::Error( + "cannot check overflow with decimalv2"); + return false; + } auto column_result = ConstOrVectorAdapter< LeftDataType, RightDataType, std::conditional_t, @@ -1007,8 +1016,7 @@ public: return false; }); if (!valid) { - return Status::RuntimeError("{}'s arguments do not match the expected data types", - get_name()); + return status; } return Status::OK();