This is an automated email from the ASF dual-hosted git repository. lihaopeng pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new 74ca21a10ed [Fix](function) fix wrong length check of function array_range (#49993) 74ca21a10ed is described below commit 74ca21a10eda3f328b1b3c9b2c46cdf5c19a4bdd Author: zclllyybb <zhaochan...@selectdb.com> AuthorDate: Fri Apr 11 21:45:41 2025 +0800 [Fix](function) fix wrong length check of function array_range (#49993) --- .../vec/functions/array/function_array_range.cpp | 4 +-- .../nereids_function_p0/scalar_function/Array.out | Bin 770235 -> 773605 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 ffb5987c744..b0a2c7e7b66 100644 --- a/be/src/vec/functions/array/function_array_range.cpp +++ b/be/src/vec/functions/array/function_array_range.cpp @@ -188,8 +188,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 4c489cfb045..d50928ca7c2 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 f4d993baf5a..2a354fddd43 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 5d957d7980d..ed34c3e4dc0 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