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


##########
be/src/vec/runtime/vdatetime_value.cpp:
##########
@@ -2300,14 +2300,28 @@ bool DateV2Value<T>::from_date_format_str(const char* 
format, int format_len, co
                 break;
             // Micro second
             case 'f':
-                tmp = val + min(6, val_end - val);
-                if (!str_to_int64(val, &tmp, &int_value)) {
-                    return false;
+                tmp = val;
+                // when there's still something to the end, fix the scale of 
ms.
+                while (tmp < val_end && isdigit(*tmp)) {
+                    tmp++;
+                }
+
+                if (tmp - val > 6) {

Review Comment:
   warning: 6 is a magic number; consider replacing it with a named constant 
[readability-magic-numbers]
   ```cpp
                   if (tmp - val > 6) {
                                   ^
   ```
   



##########
be/src/vec/runtime/vdatetime_value.cpp:
##########
@@ -2300,14 +2300,28 @@ bool DateV2Value<T>::from_date_format_str(const char* 
format, int format_len, co
                 break;
             // Micro second
             case 'f':
-                tmp = val + min(6, val_end - val);
-                if (!str_to_int64(val, &tmp, &int_value)) {
-                    return false;
+                tmp = val;
+                // when there's still something to the end, fix the scale of 
ms.
+                while (tmp < val_end && isdigit(*tmp)) {
+                    tmp++;
+                }
+
+                if (tmp - val > 6) {
+                    const char* tmp2 = val + 6;
+                    if (!str_to_int64(val, &tmp2, &int_value)) {
+                        return false;
+                    }
+                } else {
+                    if (!str_to_int64(val, &tmp, &int_value)) {
+                        return false;
+                    }
+                }
+                if constexpr (is_datetime) {
+                    microsecond = int_value * int_exp10(6 - min(6, tmp - val));

Review Comment:
   warning: 6 is a magic number; consider replacing it with a named constant 
[readability-magic-numbers]
   ```cpp
                       microsecond = int_value * int_exp10(6 - min(6, tmp - 
val));
                                                           ^
   ```
   



##########
be/src/vec/runtime/vdatetime_value.cpp:
##########
@@ -2300,14 +2300,28 @@ bool DateV2Value<T>::from_date_format_str(const char* 
format, int format_len, co
                 break;
             // Micro second
             case 'f':
-                tmp = val + min(6, val_end - val);
-                if (!str_to_int64(val, &tmp, &int_value)) {
-                    return false;
+                tmp = val;
+                // when there's still something to the end, fix the scale of 
ms.
+                while (tmp < val_end && isdigit(*tmp)) {
+                    tmp++;
+                }
+
+                if (tmp - val > 6) {
+                    const char* tmp2 = val + 6;
+                    if (!str_to_int64(val, &tmp2, &int_value)) {
+                        return false;
+                    }
+                } else {
+                    if (!str_to_int64(val, &tmp, &int_value)) {
+                        return false;
+                    }
+                }
+                if constexpr (is_datetime) {
+                    microsecond = int_value * int_exp10(6 - min(6, tmp - val));

Review Comment:
   warning: 6 is a magic number; consider replacing it with a named constant 
[readability-magic-numbers]
   ```cpp
                       microsecond = int_value * int_exp10(6 - min(6, tmp - 
val));
                                                                   ^
   ```
   



##########
be/src/vec/runtime/vdatetime_value.cpp:
##########
@@ -2300,14 +2300,28 @@ bool DateV2Value<T>::from_date_format_str(const char* 
format, int format_len, co
                 break;
             // Micro second
             case 'f':
-                tmp = val + min(6, val_end - val);
-                if (!str_to_int64(val, &tmp, &int_value)) {
-                    return false;
+                tmp = val;
+                // when there's still something to the end, fix the scale of 
ms.
+                while (tmp < val_end && isdigit(*tmp)) {
+                    tmp++;
+                }
+
+                if (tmp - val > 6) {
+                    const char* tmp2 = val + 6;

Review Comment:
   warning: 6 is a magic number; consider replacing it with a named constant 
[readability-magic-numbers]
   ```cpp
                       const char* tmp2 = val + 6;
                                                ^
   ```
   



-- 
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-unsubscr...@doris.apache.org

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


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

Reply via email to