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


##########
be/src/exprs/function/array/function_array_range.cpp:
##########
@@ -230,8 +232,15 @@ struct RangeImplUtil {
                         dest_nested_null_map.push_back(0);
                         offset++;
                         move++;
-                        idx = doris::date_time_add<UNIT::value, 
TYPE_DATETIMEV2, Int32>(idx,
-                                                                               
         step_row);
+                        auto next = idx;
+                        TimeInterval interval(UNIT::value, step_row, false);
+                        // The current value can be the last element even if 
advancing it exceeds
+                        // the DateTimeV2 range.
+                        if (!next.template 
date_add_interval<UNIT::value>(interval)) {

Review Comment:
   `move` is already the number of emitted elements, so when it equals 
1,000,000 this loop still appends element 1,000,001. If the new successor check 
then fails, this `break` returns without another size check. For example, 
`array_range(cast('9999-12-08 20:26:38' as datetimev2), cast('9999-12-31 
23:59:59' as datetimev2), interval 2 second)` spans 2,000,001 seconds, emits 
1,000,001 values through `9999-12-31 23:59:58`, and then fails to advance by 
two seconds, so it succeeds past `max_array_size_as_field`. Please enforce the 
cap before appending (for example, reject when `move >= 
max_array_size_as_field`) and add an exact max-plus-one upper-bound regression; 
`sequence` reaches the same implementation.



-- 
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