This is an automated email from the ASF dual-hosted git repository. dataroaring pushed a commit to branch branch-3.0 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push: new 45569bb3f03 branch-3.0: [Fix](function) fix wrong length check of function array_range #49993 (#49997) 45569bb3f03 is described below commit 45569bb3f037bd378043132be794c66a439e03d9 Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> AuthorDate: Tue Apr 22 11:37:07 2025 +0800 branch-3.0: [Fix](function) fix wrong length check of function array_range #49993 (#49997) Cherry-picked from #49993 Co-authored-by: zclllyybb <zhaochan...@selectdb.com> --- .../vec/functions/array/function_array_range.cpp | 4 +-- .../nereids_function_p0/scalar_function/Array.out | Bin 769953 -> 773323 bytes .../scalar_function/Array.groovy | 33 +++++++++------------ .../array_functions/test_array_functions.groovy | 22 -------------- 4 files changed, 16 insertions(+), 43 deletions(-) diff --git a/be/src/vec/functions/array/function_array_range.cpp b/be/src/vec/functions/array/function_array_range.cpp index 1a5dd08aaac..888d7adc5f9 100644 --- a/be/src/vec/functions/array/function_array_range.cpp +++ b/be/src/vec/functions/array/function_array_range.cpp @@ -197,8 +197,8 @@ private: continue; } else { if (idx < end_row && step_row > 0 && - ((static_cast<__int128_t>(end_row) - static_cast<__int128_t>(step_row) - - 1) / static_cast<__int128_t>(step_row) + + ((static_cast<__int128_t>(end_row) - static_cast<__int128_t>(idx) - 1) / + static_cast<__int128_t>(step_row) + 1) > max_array_size_as_field) { return Status::InvalidArgument("Array size exceeds the limit {}", max_array_size_as_field); diff --git a/regression-test/data/nereids_function_p0/scalar_function/Array.out b/regression-test/data/nereids_function_p0/scalar_function/Array.out index b2e11fab37e..30f42223f3b 100644 Binary files a/regression-test/data/nereids_function_p0/scalar_function/Array.out and b/regression-test/data/nereids_function_p0/scalar_function/Array.out differ diff --git a/regression-test/suites/nereids_function_p0/scalar_function/Array.groovy b/regression-test/suites/nereids_function_p0/scalar_function/Array.groovy index d7faedce887..ae6193d3737 100644 --- a/regression-test/suites/nereids_function_p0/scalar_function/Array.groovy +++ b/regression-test/suites/nereids_function_p0/scalar_function/Array.groovy @@ -1281,30 +1281,25 @@ suite("nereids_scalar_fn_Array") { qt_sequence_datetime_hour """select sequence(kdtmv2s1, date_add(kdtmv2s1, interval kint-3 hour), interval kint hour) from fn_test order by kdtmv2s1;""" qt_sequence_datetime_minute """select sequence(kdtmv2s1, date_add(kdtmv2s1, interval kint+1 minute), interval kint minute) from fn_test order by kdtmv2s1;""" qt_sequence_datetime_second """select sequence(kdtmv2s1, date_add(kdtmv2s1, interval kint second), interval kint-1 second) from fn_test order by kdtmv2s1;""" - // make large error size - test { - sql "select array_size(sequence(kdtmv2s1, date_add(kdtmv2s1, interval kint+1000 year), interval kint hour)) from fn_test order by kdtmv2s1;" - check{result, exception, startTime, endTime -> - assertTrue(exception != null) - logger.info(exception.message) - } - } + + // max_array_size_as_field = 1000000; + sql "select count(sequence(kdtmv2s1, date_add(kdtmv2s1, interval kint+1000 year))) from fn_test" + sql "select count(sequence(kdtmv2s1, date_add(kdtmv2s1, interval kint+1000 year), INTERVAL 5 YEAR)) from fn_test" + order_qt_sql_sequence_dt_3args "select sequence(kdtmv2s1, date_add(kdtmv2s1, interval kint+1000 year), INTERVAL 125 YEAR) from fn_test" + sql "select count(sequence(kint, kint+100000)) from fn_test" + sql "select count(sequence(kint, kint+100000, 10000)) from fn_test" + order_qt_sql_sequence_int_3args "select sequence(kint, kint+100000, 10000) from fn_test" test { - sql "select array_size(sequence(kdtmv2s1, date_add(kdtmv2s1, interval kint+10000 month), interval kint hour)) from fn_test order by kdtmv2s1;" - check{result, exception, startTime, endTime -> - assertTrue(exception != null) - logger.info(exception.message) - } + sql "select sequence(kdtmv2s1, date_add(kdtmv2s1, interval 5000 year), interval 1 second) from fn_test" + exception "Array size exceeds the limit 1000000" } - + sql "select sequence(kdtmv2s1, date_add(kdtmv2s1, interval 5000 year), interval 500 year) from fn_test" test { - sql "select array_size(sequence(kdtmv2s1, date_add(kdtmv2s1, interval kint+1000001 day), interval kint day)) from fn_test order by kdtmv2s1;" - check{result, exception, startTime, endTime -> - assertTrue(exception != null) - logger.info(exception.message) - } + sql "select count(sequence(kint, kint+10000000)) from fn_test" + exception "Array size exceeds the limit 1000000" } + sql "select count(sequence(kint, kint+10000000, 50)) from fn_test" // with array empty qt_array_empty_fe """select array()""" diff --git a/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions.groovy b/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions.groovy index 96bca3eb4ff..ac12b1ffccb 100644 --- a/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions.groovy +++ b/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions.groovy @@ -421,26 +421,4 @@ suite("test_array_functions") { qt_const_select "select sequence(cast('2022-35-38 12:00:10' as datetimev2(0)), cast('2022-05-18 22:00:30' as datetimev2(0))); " qt_const_select "select sequence(1, 10, 0); " qt_const_select "select sequence(cast('2022-05-15 12:00:00' as datetimev2(0)), cast('2022-05-17 12:00:00' as datetimev2(0)), interval 0 day); " - // test large size of array - test { - sql """ select sequence(cast('2022-05-01 12:00:00' as datetimev2(0)), cast('2022-05-17 12:00:00' as datetimev2(0)), interval 10000000000 week); """ - check{result, exception, startTime, endTime -> - assertTrue(exception != null) - logger.info(exception.message) - } - } - test { - sql """ select sequence(1, 10000000000); """ - check{result, exception, startTime, endTime -> - assertTrue(exception != null) - logger.info(exception.message) - } - } - test { - sql """ select sequence(1, 10000000000, 2); """ - check{result, exception, startTime, endTime -> - assertTrue(exception != null) - logger.info(exception.message) - } - } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org