You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "zclllyybb (via GitHub)" <gi...@apache.org> on 2024/06/12 03:39:37 UTC

[PR] [branch-2.1](function) fix date_format and from_unixtime core when meet long format string (#35883) [doris]

zclllyybb opened a new pull request, #36158:
URL: https://github.com/apache/doris/pull/36158

   ## Proposed changes
   before:
   crash
   
   now:
   ```sql
   mysql> SELECT  DATE_FORMAT('2011-06-24', '%f %V %f %l %V %I %S %p %w %r %j %f %l %I %D %w %j %D %e %s %V %f %D %M %s %X %U %v %c %u %x %r %j %a %h %s %m %a %v %u %b');
   +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | date_format(cast('2011-06-24' as DATETIMEV2(0)), '%f %V %f %l %V %I %S %p %w %r %j %f %l %I %D %w %j %D %e %s %V %f %D %M %s %X %U %v %c %u %x %r %j %a %h %s %m %a %v %u %b') |
   +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | NULL                                                                                                                                                                           |
   +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   1 row in set (0.80 sec)
   ```
   


-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [branch-2.1](function) fix date_format and from_unixtime core when meet long format string (#35883) [doris]

Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #36158:
URL: https://github.com/apache/doris/pull/36158#issuecomment-2162114921

   TeamCity be ut coverage result:
    Function Coverage: 36.29% (9124/25141) 
    Line Coverage: 27.78% (74225/267153)
    Region Coverage: 26.72% (38300/143363)
    Branch Coverage: 23.39% (19397/82914)
    Coverage Report: http://coverage.selectdb-in.cc/coverage/0809bc29d3fb94ee41175db1ca78a23296845a8f_0809bc29d3fb94ee41175db1ca78a23296845a8f/report/index.html


-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [branch-2.1](function) fix date_format and from_unixtime core when meet long format string (#35883) [doris]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on code in PR #36158:
URL: https://github.com/apache/doris/pull/36158#discussion_r1635774851


##########
be/src/vec/runtime/vdatetime_value.cpp:
##########
@@ -3421,10 +3426,12 @@
 }
 
 template <typename T>
-bool DateV2Value<T>::to_format_string(const char* format, int len, char* to) const {
+bool DateV2Value<T>::to_format_string_conservative(const char* format, int len, char* to,

Review Comment:
   warning: function 'to_format_string_conservative' exceeds recommended size/complexity thresholds [readability-function-size]
   ```cpp
   bool DateV2Value<T>::to_format_string_conservative(const char* format, int len, char* to,
                        ^
   ```
   <details>
   <summary>Additional context</summary>
   
   **be/src/vec/runtime/vdatetime_value.cpp:3428:** 256 lines including whitespace and comments (threshold 80)
   ```cpp
   bool DateV2Value<T>::to_format_string_conservative(const char* format, int len, char* to,
                        ^
   ```
   
   </details>
   



##########
be/src/vec/runtime/vdatetime_value.cpp:
##########
@@ -673,10 +672,12 @@
     return dst + 4;
 }
 
-bool VecDateTimeValue::to_format_string(const char* format, int len, char* to) const {
+bool VecDateTimeValue::to_format_string_conservative(const char* format, int len, char* to,

Review Comment:
   warning: function 'to_format_string_conservative' exceeds recommended size/complexity thresholds [readability-function-size]
   ```cpp
   bool VecDateTimeValue::to_format_string_conservative(const char* format, int len, char* to,
                          ^
   ```
   <details>
   <summary>Additional context</summary>
   
   **be/src/vec/runtime/vdatetime_value.cpp:674:** 270 lines including whitespace and comments (threshold 80)
   ```cpp
   bool VecDateTimeValue::to_format_string_conservative(const char* format, int len, char* to,
                          ^
   ```
   
   </details>
   



##########
be/src/vec/runtime/vdatetime_value.cpp:
##########
@@ -673,10 +672,12 @@ char* write_four_digits_to_string(int number, char* dst) {
     return dst + 4;
 }
 
-bool VecDateTimeValue::to_format_string(const char* format, int len, char* to) const {
+bool VecDateTimeValue::to_format_string_conservative(const char* format, int len, char* to,

Review Comment:
   warning: function 'to_format_string_conservative' has cognitive complexity of 60 (threshold 50) [readability-function-cognitive-complexity]
   ```cpp
   bool VecDateTimeValue::to_format_string_conservative(const char* format, int len, char* to,
                          ^
   ```
   <details>
   <summary>Additional context</summary>
   
   **be/src/vec/runtime/vdatetime_value.cpp:676:** +1, including nesting penalty of 0, nesting level increased to 1
   ```cpp
       if (check_range(_year, _month, _day, _hour, _minute, _second, _type)) {
       ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:687:** +1, including nesting penalty of 0, nesting level increased to 1
   ```cpp
       while (ptr < end) {
       ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:688:** +2, including nesting penalty of 1, nesting level increased to 2
   ```cpp
           if (to - begin + SAFE_FORMAT_STRING_MARGIN > max_valid_length) [[unlikely]] {
           ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:691:** +2, including nesting penalty of 1, nesting level increased to 2
   ```cpp
           if (*ptr != '%' || (ptr + 1) == end) {
           ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:691:** +1
   ```cpp
           if (*ptr != '%' || (ptr + 1) == end) {
                           ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:697:** +2, including nesting penalty of 1, nesting level increased to 2
   ```cpp
           switch (ch = *ptr++) {
           ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:748:** +3, including nesting penalty of 2, nesting level increased to 3
   ```cpp
               if (_type == TIME_TIME || (_year == 0 && _month == 0)) {
               ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:748:** +1
   ```cpp
               if (_type == TIME_TIME || (_year == 0 && _month == 0)) {
                                      ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:748:** +1
   ```cpp
               if (_type == TIME_TIME || (_year == 0 && _month == 0)) {
                                                     ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:755:** +3, including nesting penalty of 2, nesting level increased to 3
   ```cpp
               if (_month == 0) {
               ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:769:** +3, including nesting penalty of 2, nesting level increased to 3
   ```cpp
               if (_day >= 10 && _day <= 19) {
               ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:769:** +1
   ```cpp
               if (_day >= 10 && _day <= 19) {
                              ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:771:** +1, nesting level increased to 3
   ```cpp
               } else {
                 ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:772:** +4, including nesting penalty of 3, nesting level increased to 4
   ```cpp
                   switch (_day % 10) {
                   ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:815:** +3, including nesting penalty of 2, nesting level increased to 3
   ```cpp
               if (_month == 0) {
               ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:822:** +3, including nesting penalty of 2, nesting level increased to 3
   ```cpp
               if ((_hour % 24) >= 12) {
               ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:824:** +1, nesting level increased to 3
   ```cpp
               } else {
                 ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:840:** +3, including nesting penalty of 2, nesting level increased to 3
   ```cpp
               if ((_hour % 24) >= 12) {
               ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:842:** +1, nesting level increased to 3
   ```cpp
               } else {
                 ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:862:** +3, including nesting penalty of 2, nesting level increased to 3
   ```cpp
               if (_type == TIME_TIME) {
               ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:872:** +3, including nesting penalty of 2, nesting level increased to 3
   ```cpp
               if (_type == TIME_TIME) {
               ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:882:** +3, including nesting penalty of 2, nesting level increased to 3
   ```cpp
               if (_type == TIME_TIME) {
               ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:892:** +3, including nesting penalty of 2, nesting level increased to 3
   ```cpp
               if (_type == TIME_TIME) {
               ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:901:** +3, including nesting penalty of 2, nesting level increased to 3
   ```cpp
               if (_type == TIME_TIME || (_month == 0 && _year == 0)) {
               ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:901:** +1
   ```cpp
               if (_type == TIME_TIME || (_month == 0 && _year == 0)) {
                                      ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:901:** +1
   ```cpp
               if (_type == TIME_TIME || (_month == 0 && _year == 0)) {
                                                      ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:914:** +3, including nesting penalty of 2, nesting level increased to 3
   ```cpp
               if (_type == TIME_TIME) {
               ^
   ```
   **be/src/vec/runtime/vdatetime_value.cpp:927:** +3, including nesting penalty of 2, nesting level increased to 3
   ```cpp
               if (_type == TIME_TIME) {
               ^
   ```
   
   </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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [branch-2.1](function) fix date_format and from_unixtime core when meet long format string (#35883) [doris]

Posted by "zclllyybb (via GitHub)" <gi...@apache.org>.
zclllyybb commented on PR #36158:
URL: https://github.com/apache/doris/pull/36158#issuecomment-2162043840

   run buildall


-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [branch-2.1](function) fix date_format and from_unixtime core when meet long format string (#35883) [doris]

Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #36158:
URL: https://github.com/apache/doris/pull/36158#issuecomment-2162043060

   Thank you for your contribution to Apache Doris.
   Don't know what should be done next? See [How to process your PR](https://cwiki.apache.org/confluence/display/DORIS/How+to+process+your+PR)
   
   Since 2024-03-18, the Document has been moved to [doris-website](https://github.com/apache/doris-website).
   See [Doris Document](https://cwiki.apache.org/confluence/display/DORIS/Doris+Document).


-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org