diff --git a/be/src/vec/functions/int_div.h b/be/src/vec/functions/int_div.h index a74ecab413..1bfebcb538 100644 --- a/be/src/vec/functions/int_div.h +++ b/be/src/vec/functions/int_div.h @@ -20,21 +20,11 @@ #pragma once -#include "common/compiler_util.h" -#include "common/logging.h" -#include "common/status.h" -#include "runtime/decimalv2_value.h" -#include "type_traits" #include "vec/columns/column_nullable.h" -#include "vec/common/exception.h" #include "vec/data_types/number_traits.h" namespace doris::vectorized { -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-compare" -#pragma GCC diagnostic pop - template struct DivideIntegralImpl { using ResultType = typename NumberTraits::ResultOfIntegerDivision::Type; @@ -42,14 +32,7 @@ struct DivideIntegralImpl { template static inline Result apply(A a, B b, NullMap& null_map, size_t index) { null_map[index] = b == 0; - - /// Otherwise overflow may occur due to integer promotion. Example: int8_t(-1) / uint64_t(2). - /// NOTE: overflow is still possible when dividing large signed number to large unsigned number or vice-versa. But it's less harmful. - if constexpr (std::is_integral_v && std::is_integral_v && - (std::is_signed_v || std::is_signed_v)) - return std::make_signed_t(a) / (std::make_signed_t(b) + (b == 0)); - else - return a / (b + (b == 0)); + return a / (b + null_map[index]); } };