Uh oh!
There was an error while loading. Please reload this page.
[improvement](decimal) use new way for decimal arithmetic precision promotion - #27787
Conversation
Uh oh!
There was an error while loading. Please reload this page.
| } while (0) | ||
| #define THROW_ARITHMETIC_OVERFLOW_ERRROR \ | ||
| throw Exception(ErrorCode::ARITHMETIC_OVERFLOW_ERRROR, "Arithmetic overflow") |
There was a problem hiding this comment.
this macro is not reasonable.
If we define such a macro, then we may need define many many macros... each error code need a macro
| template <typename T> | ||
| constexpr vectorized::UInt32 get_number_max_digits() { | ||
| if constexpr (std::is_same_v<T, vectorized::UInt8> || std::is_same_v<T, vectorized::Int8>) { |
Uh oh!
There was an error while loading. Please reload this page.
| if constexpr (narrow_integral) { | ||
| LOG(WARNING) << "multiply narrow scale, negative, narrow integral"; | ||
| if (UNLIKELY(converted_value.value < min_result.value)) { | ||
| THROW_ARITHMETIC_OVERFLOW_ERRROR; |
There was a problem hiding this comment.
throw exception is better than macro
ce957ef to
531a3b1Comparejacktengg
commented
Nov 30, 2023
run buildall |
ccccbcb to
c691eafComparejacktengg
commented
Dec 1, 2023
run buildall |
603533a to
a069f25Comparejacktengg
commented
Dec 3, 2023
run buildall |
jacktengg
commented
Dec 4, 2023
run pipelinex_p0 |
3eb6ea5 to
59a633eComparejacktengg
commented
Dec 4, 2023
run buildall |
1 similar comment
jacktengg
commented
Dec 4, 2023
run buildall |
3608c81 to
0676754Compare| return Status::Error<false>(e.code(), e.to_string()); \ | ||
| } \ | ||
| } while (0) | ||
| } while (0) No newline at end of file |
0676754 to
e01c532Comparejacktengg
commented
Dec 4, 2023
run buildall |
doris-robot
commented
Dec 4, 2023
(From new machine)TeamCity pipeline, clickbench performance test result: |
61c9d6a to
8c126c0Comparejacktengg
commented
Dec 4, 2023
run buildall |
…tic precision promotion 1. [DNM](decimal) use new way for decimal arithmetic precision promotion 2. throw exception if it overflows for decimal arithmetics 3. throw exception if it overflows when casting among number types
55be2d3 to
4f14b9aComparejacktengg
commented
Dec 4, 2023
run buildall |
| /// there's implicit type conversion here | ||
| static ALWAYS_INLINE NativeResultType apply(NativeResultType a, NativeResultType b) { | ||
| template <bool need_adjust_scale> | ||
| static ALWAYS_INLINE NativeResultType apply(NativeResultType a, NativeResultType b, |
There was a problem hiding this comment.
warning: function 'apply' has cognitive complexity of 61 (threshold 50) [readability-function-cognitive-complexity]
staticALWAYS_INLINE NativeResultType apply(NativeResultType a, NativeResultType b,
^Additional context
be/src/vec/functions/function_binary_arithmetic.h:519: +1, including nesting penalty of 0, nesting level increased to 1
ifconstexpr (IsDecimalV2<B> || IsDecimalV2<A>) {
^be/src/vec/functions/function_binary_arithmetic.h:519: +1
ifconstexpr (IsDecimalV2<B> || IsDecimalV2<A>) {
^be/src/vec/functions/function_binary_arithmetic.h:523: +1, nesting level increased to 1
} else {
^be/src/vec/functions/function_binary_arithmetic.h:525: +2, including nesting penalty of 1, nesting level increased to 2
ifconstexpr (OpTraits::can_overflow && check_overflow) {
^be/src/vec/functions/function_binary_arithmetic.h:527: +3, including nesting penalty of 2, nesting level increased to 3
if (UNLIKELY(Op::template apply<NativeResultType>(a, b, res))) {
^be/src/vec/functions/function_binary_arithmetic.h:528: +4, including nesting penalty of 3, nesting level increased to 4
ifconstexpr (OpTraits::is_plus_minus) {
^be/src/vec/functions/function_binary_arithmetic.h:533: +4, including nesting penalty of 3, nesting level increased to 4
ifconstexpr (std::is_same_v<NativeResultType, __int128>) {
^be/src/vec/functions/function_binary_arithmetic.h:535: +5, including nesting penalty of 4, nesting level increased to 5
ifconstexpr (OpTraits::is_multiply && need_adjust_scale) {
^be/src/vec/functions/function_binary_arithmetic.h:536: +6, including nesting penalty of 5, nesting level increased to 6
if (res256 > 0) {
^be/src/vec/functions/function_binary_arithmetic.h:540: +1, nesting level increased to 6
} else {
^be/src/vec/functions/function_binary_arithmetic.h:546: +5, including nesting penalty of 4, nesting level increased to 5
if (res256 > wide::Int256(max_result_number.value) ||
^be/src/vec/functions/function_binary_arithmetic.h:546: +1
if (res256 > wide::Int256(max_result_number.value) ||
^be/src/vec/functions/function_binary_arithmetic.h:550: +1, nesting level increased to 5
} else {
^be/src/vec/functions/function_binary_arithmetic.h:553: +1, nesting level increased to 4
} else {
^be/src/vec/functions/function_binary_arithmetic.h:557: +1, nesting level increased to 3
} else {
^be/src/vec/functions/function_binary_arithmetic.h:559: +4, including nesting penalty of 3, nesting level increased to 4
ifconstexpr (OpTraits::is_multiply && need_adjust_scale) {
^be/src/vec/functions/function_binary_arithmetic.h:560: +5, including nesting penalty of 4, nesting level increased to 5
if (res >= 0) {
^be/src/vec/functions/function_binary_arithmetic.h:563: +1, nesting level increased to 5
} else {
^be/src/vec/functions/function_binary_arithmetic.h:568: +4, including nesting penalty of 3, nesting level increased to 4
if (res > max_result_number.value ||
^be/src/vec/functions/function_binary_arithmetic.h:568: +1
if (res > max_result_number.value ||
^be/src/vec/functions/function_binary_arithmetic.h:575: +1, nesting level increased to 2
} else {
^be/src/vec/functions/function_binary_arithmetic.h:577: +3, including nesting penalty of 2, nesting level increased to 3
ifconstexpr (OpTraits::is_multiply && need_adjust_scale) {
^be/src/vec/functions/function_binary_arithmetic.h:578: +4, including nesting penalty of 3, nesting level increased to 4
if (res >= 0) {
^be/src/vec/functions/function_binary_arithmetic.h:580: +1, nesting level increased to 4
} else {
^| /// there's implicit type conversion here | ||
| static ALWAYS_INLINE NativeResultType apply(NativeResultType a, NativeResultType b) { | ||
| template <bool need_adjust_scale> | ||
| static ALWAYS_INLINE NativeResultType apply(NativeResultType a, NativeResultType b, |
There was a problem hiding this comment.
warning: function 'apply' has cognitive complexity of 61 (threshold 50) [readability-function-cognitive-complexity]
staticALWAYS_INLINE NativeResultType apply(NativeResultType a, NativeResultType b,
^Additional context
be/src/vec/functions/function_binary_arithmetic.h:519: +1, including nesting penalty of 0, nesting level increased to 1
ifconstexpr (IsDecimalV2<B> || IsDecimalV2<A>) {
^be/src/vec/functions/function_binary_arithmetic.h:519: +1
ifconstexpr (IsDecimalV2<B> || IsDecimalV2<A>) {
^be/src/vec/functions/function_binary_arithmetic.h:523: +1, nesting level increased to 1
} else {
^be/src/vec/functions/function_binary_arithmetic.h:525: +2, including nesting penalty of 1, nesting level increased to 2
ifconstexpr (OpTraits::can_overflow && check_overflow) {
^be/src/vec/functions/function_binary_arithmetic.h:527: +3, including nesting penalty of 2, nesting level increased to 3
if (UNLIKELY(Op::template apply<NativeResultType>(a, b, res))) {
^be/src/vec/functions/function_binary_arithmetic.h:528: +4, including nesting penalty of 3, nesting level increased to 4
ifconstexpr (OpTraits::is_plus_minus) {
^be/src/vec/functions/function_binary_arithmetic.h:533: +4, including nesting penalty of 3, nesting level increased to 4
ifconstexpr (std::is_same_v<NativeResultType, __int128>) {
^be/src/vec/functions/function_binary_arithmetic.h:535: +5, including nesting penalty of 4, nesting level increased to 5
ifconstexpr (OpTraits::is_multiply && need_adjust_scale) {
^be/src/vec/functions/function_binary_arithmetic.h:536: +6, including nesting penalty of 5, nesting level increased to 6
if (res256 > 0) {
^be/src/vec/functions/function_binary_arithmetic.h:540: +1, nesting level increased to 6
} else {
^be/src/vec/functions/function_binary_arithmetic.h:546: +5, including nesting penalty of 4, nesting level increased to 5
if (res256 > wide::Int256(max_result_number.value) ||
^be/src/vec/functions/function_binary_arithmetic.h:546: +1
if (res256 > wide::Int256(max_result_number.value) ||
^be/src/vec/functions/function_binary_arithmetic.h:550: +1, nesting level increased to 5
} else {
^be/src/vec/functions/function_binary_arithmetic.h:553: +1, nesting level increased to 4
} else {
^be/src/vec/functions/function_binary_arithmetic.h:557: +1, nesting level increased to 3
} else {
^be/src/vec/functions/function_binary_arithmetic.h:559: +4, including nesting penalty of 3, nesting level increased to 4
ifconstexpr (OpTraits::is_multiply && need_adjust_scale) {
^be/src/vec/functions/function_binary_arithmetic.h:560: +5, including nesting penalty of 4, nesting level increased to 5
if (res >= 0) {
^be/src/vec/functions/function_binary_arithmetic.h:563: +1, nesting level increased to 5
} else {
^be/src/vec/functions/function_binary_arithmetic.h:568: +4, including nesting penalty of 3, nesting level increased to 4
if (res > max_result_number.value || res < -max_result_number.value) {
^be/src/vec/functions/function_binary_arithmetic.h:568: +1
if (res > max_result_number.value || res < -max_result_number.value) {
^be/src/vec/functions/function_binary_arithmetic.h:574: +1, nesting level increased to 2
} else {
^be/src/vec/functions/function_binary_arithmetic.h:576: +3, including nesting penalty of 2, nesting level increased to 3
ifconstexpr (OpTraits::is_multiply && need_adjust_scale) {
^be/src/vec/functions/function_binary_arithmetic.h:577: +4, including nesting penalty of 3, nesting level increased to 4
if (res >= 0) {
^be/src/vec/functions/function_binary_arithmetic.h:579: +1, nesting level increased to 4
} else {
^jacktengg
commented
Dec 4, 2023
run feut |
PR approved by at least one committer and no changes requested. |
PR approved by anyone and no changes requested. |
…romotion (apache#27787) * [DNM](decimal) use new way for decimal arithmetic precision promotion * [improvement](decimal) [DNM](decimal) use new way for decimal arithmetic precision promotion 1. [DNM](decimal) use new way for decimal arithmetic precision promotion 2. throw exception if it overflows for decimal arithmetics 3. throw exception if it overflows when casting among number types * fix compile error of gcc * improvement --------- Co-authored-by: morrySnow <morrysnow@126.com>
Proposed changes
Issue Number: close #xxx
FE changes from #27492
decimalv3: use 38, min(decimalOverflowScale, ret_scale) as result precision if overflow
decimalv2 with largeint or bigint will promotion to decimalv3
decimalOverflowScale could be config by session variable
BE:
Further comments
If this is a relatively large or complex change, kick off the discussion at dev@doris.apache.org by explaining why you chose the solution you did and what alternatives you considered, etc...