github-actions[bot] commented on code in PR #32518:
URL: https://github.com/apache/doris/pull/32518#discussion_r1547823646


##########
be/src/vec/data_types/data_type_decimal.h:
##########
@@ -410,40 +411,113 @@ template <typename DataType>
 constexpr bool IsDataTypeDecimalOrNumber =
         IsDataTypeDecimal<DataType> || IsDataTypeNumber<DataType>;
 
-// only for casting between other integral types and decimals
+// This function handles cast from data/datetime/integral types to decimals
 template <typename FromDataType, typename ToDataType, bool 
multiply_may_overflow,
           bool narrow_integral, typename RealFrom, typename RealTo>
-    requires IsDataTypeDecimal<FromDataType> && IsDataTypeDecimal<ToDataType>
+    requires(IsDataTypeDecimal<FromDataType> || IsDateV2Type<FromDataType> ||
+             IsDateTimeV2Type<FromDataType>) &&
+            IsDataTypeDecimal<ToDataType>
 void convert_to_decimals(RealTo* dst, const RealFrom* src, UInt32 scale_from, 
UInt32 scale_to,

Review Comment:
   warning: function 'convert_to_decimals' has cognitive complexity of 75 
(threshold 50) [readability-function-cognitive-complexity]
   ```cpp
   void convert_to_decimals(RealTo* dst, const RealFrom* src, UInt32 
scale_from, UInt32 scale_to,
        ^
   ```
   <details>
   <summary>Additional context</summary>
   
   **be/src/vec/data_types/data_type_decimal.h:433:** +1, including nesting 
penalty of 0, nesting level increased to 1
   ```cpp
       if constexpr (IsDateV2Type<FromDataType>) {
       ^
   ```
   **be/src/vec/data_types/data_type_decimal.h:435:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           for (size_t i = 0; i < size; i++) {
           ^
   ```
   **be/src/vec/data_types/data_type_decimal.h:436:** +3, including nesting 
penalty of 2, nesting level increased to 3
   ```cpp
               if constexpr (multiply_may_overflow) {
               ^
   ```
   **be/src/vec/data_types/data_type_decimal.h:439:** +4, including nesting 
penalty of 3, nesting level increased to 4
   ```cpp
                   if 
(common::mul_overflow(static_cast<MaxFieldType>(res).value, multiplier.value,
                   ^
   ```
   **be/src/vec/data_types/data_type_decimal.h:444:** +4, including nesting 
penalty of 3, nesting level increased to 4
   ```cpp
                   if constexpr (narrow_integral) {
                   ^
   ```
   **be/src/vec/data_types/data_type_decimal.h:445:** +5, including nesting 
penalty of 4, nesting level increased to 5
   ```cpp
                       if (tmp.value < min_result.value || tmp.value > 
max_result.value) {
                       ^
   ```
   **be/src/vec/data_types/data_type_decimal.h:445:** +1
   ```cpp
                       if (tmp.value < min_result.value || tmp.value > 
max_result.value) {
                                                        ^
   ```
   **be/src/vec/data_types/data_type_decimal.h:453:** +1, nesting level 
increased to 3
   ```cpp
               } else {
                 ^
   ```
   **be/src/vec/data_types/data_type_decimal.h:459:** +1, nesting level 
increased to 1
   ```cpp
       } else if constexpr (IsDateTimeV2Type<FromDataType>) {
              ^
   ```
   **be/src/vec/data_types/data_type_decimal.h:461:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           for (size_t i = 0; i < size; i++) {
           ^
   ```
   **be/src/vec/data_types/data_type_decimal.h:465:** +3, including nesting 
penalty of 2, nesting level increased to 3
   ```cpp
               if (scale_to < 6) {
               ^
   ```
   **be/src/vec/data_types/data_type_decimal.h:469:** +1, nesting level 
increased to 3
   ```cpp
               } else {
                 ^
   ```
   **be/src/vec/data_types/data_type_decimal.h:474:** +3, including nesting 
penalty of 2, nesting level increased to 3
   ```cpp
               if constexpr (multiply_may_overflow) {
               ^
   ```
   **be/src/vec/data_types/data_type_decimal.h:478:** +4, including nesting 
penalty of 3, nesting level increased to 4
   ```cpp
                   if 
(common::mul_overflow(static_cast<MaxFieldType>(res).value, multiplier.value,
                   ^
   ```
   **be/src/vec/data_types/data_type_decimal.h:482:** +4, including nesting 
penalty of 3, nesting level increased to 4
   ```cpp
                   if constexpr (narrow_integral) {
                   ^
   ```
   **be/src/vec/data_types/data_type_decimal.h:483:** +5, including nesting 
penalty of 4, nesting level increased to 5
   ```cpp
                       if (tmp.value + datetime_offset < min_result.value ||
                       ^
   ```
   **be/src/vec/data_types/data_type_decimal.h:483:** +1
   ```cpp
                       if (tmp.value + datetime_offset < min_result.value ||
                                                                          ^
   ```
   **be/src/vec/data_types/data_type_decimal.h:492:** +1, nesting level 
increased to 3
   ```cpp
               } else {
                 ^
   ```
   **be/src/vec/data_types/data_type_decimal.h:500:** +1, nesting level 
increased to 1
   ```cpp
       } else {
         ^
   ```
   **be/src/vec/data_types/data_type_decimal.h:502:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           for (size_t i = 0; i < size; i++) {
           ^
   ```
   **be/src/vec/data_types/data_type_decimal.h:503:** +3, including nesting 
penalty of 2, nesting level increased to 3
   ```cpp
               if constexpr (multiply_may_overflow) {
               ^
   ```
   **be/src/vec/data_types/data_type_decimal.h:504:** +4, including nesting 
penalty of 3, nesting level increased to 4
   ```cpp
                   if 
(common::mul_overflow(static_cast<MaxFieldType>(src[i]).value, multiplier.value,
                   ^
   ```
   **be/src/vec/data_types/data_type_decimal.h:508:** +4, including nesting 
penalty of 3, nesting level increased to 4
   ```cpp
                   if constexpr (narrow_integral) {
                   ^
   ```
   **be/src/vec/data_types/data_type_decimal.h:509:** +5, including nesting 
penalty of 4, nesting level increased to 5
   ```cpp
                       if (tmp.value < min_result.value || tmp.value > 
max_result.value) {
                       ^
   ```
   **be/src/vec/data_types/data_type_decimal.h:509:** +1
   ```cpp
                       if (tmp.value < min_result.value || tmp.value > 
max_result.value) {
                                                        ^
   ```
   **be/src/vec/data_types/data_type_decimal.h:517:** +1, nesting level 
increased to 3
   ```cpp
               } else {
                 ^
   ```
   **be/src/vec/data_types/data_type_decimal.h:523:** +1, including nesting 
penalty of 0, nesting level increased to 1
   ```cpp
       if constexpr (!multiply_may_overflow && narrow_integral) {
       ^
   ```
   **be/src/vec/data_types/data_type_decimal.h:523:** +1
   ```cpp
       if constexpr (!multiply_may_overflow && narrow_integral) {
                                            ^
   ```
   **be/src/vec/data_types/data_type_decimal.h:524:** +2, including nesting 
penalty of 1, nesting level increased to 2
   ```cpp
           for (size_t i = 0; i < size; i++) {
           ^
   ```
   **be/src/vec/data_types/data_type_decimal.h:525:** +3, including nesting 
penalty of 2, nesting level increased to 3
   ```cpp
               if (dst[i].value < min_result.value || dst[i].value > 
max_result.value) {
               ^
   ```
   **be/src/vec/data_types/data_type_decimal.h:525:** +1
   ```cpp
               if (dst[i].value < min_result.value || dst[i].value > 
max_result.value) {
                                                   ^
   ```
   
   </details>
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to