This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push:
new 947d7594c8a [fix](func)fix array_with_const with larger than
max_array_size (#38152)
947d7594c8a is described below
commit 947d7594c8ae8221a93c121f5d9cdc11040127f5
Author: amory <[email protected]>
AuthorDate: Sat Jul 20 00:19:00 2024 +0800
[fix](func)fix array_with_const with larger than max_array_size (#38152)
## Proposed changes
backport: https://github.com/apache/doris/pull/37495
Issue Number: close #xxx
<!--Describe your changes.-->
---
.../array/function_array_with_constant.cpp | 6 +++---
.../test_array_functions_array_with_const.groovy | 22 ++++++++++++++++++++--
2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/be/src/vec/functions/array/function_array_with_constant.cpp
b/be/src/vec/functions/array/function_array_with_constant.cpp
index bb3cbb53e41..16e3947714c 100644
--- a/be/src/vec/functions/array/function_array_with_constant.cpp
+++ b/be/src/vec/functions/array/function_array_with_constant.cpp
@@ -91,9 +91,9 @@ public:
array_sizes.reserve(input_rows_count);
for (size_t i = 0; i < input_rows_count; ++i) {
auto array_size = num->get_int(i);
- if (UNLIKELY(array_size < 0)) {
- return Status::RuntimeError("Array size can not be negative in
function:" +
- get_name());
+ if (UNLIKELY(array_size < 0) || UNLIKELY(array_size >
max_array_size_as_field)) {
+ return Status::RuntimeError("Array size should in range(0, {})
in function: {}",
+ max_array_size_as_field,
get_name());
}
offset += array_size;
offsets.push_back(offset);
diff --git
a/regression-test/suites/datatype_p0/nested_types/query/array_functions/test_array_functions_array_with_const.groovy
b/regression-test/suites/datatype_p0/nested_types/query/array_functions/test_array_functions_array_with_const.groovy
index a155210fc50..087054d35e2 100644
---
a/regression-test/suites/datatype_p0/nested_types/query/array_functions/test_array_functions_array_with_const.groovy
+++
b/regression-test/suites/datatype_p0/nested_types/query/array_functions/test_array_functions_array_with_const.groovy
@@ -16,6 +16,7 @@
// under the License.
suite("test_array_functions_array_with_const", "p0") {
+ sql "set enable_nereids_planner=false;"
//array_with_constant
qt_old_sql "SELECT 'array_with_constant';"
order_qt_old_sql "SELECT array_with_constant(3, number) FROM numbers limit
10;"
@@ -31,7 +32,16 @@ suite("test_array_functions_array_with_const", "p0") {
SELECT array_with_constant(-231.37104, -138);
"""
} catch (Exception ex) {
- assertTrue(ex.getMessage().contains("Array size can not be negative in
function:array_with_constant"))
+ assertTrue(ex.getMessage().contains("Array size should in range(0,
1000000) in function"))
+ }
+
+ // -- {server for large array}
+ try {
+ sql """
+ SELECT array_with_constant(1000001, 1);
+ """
+ } catch (Exception ex) {
+ assertTrue(ex.getMessage().contains("Array size should in range(0,
1000000) in function"))
}
@@ -53,7 +63,15 @@ suite("test_array_functions_array_with_const", "p0") {
SELECT array_with_constant(-231.37104, -138);
"""
} catch (Exception ex) {
- assertTrue(ex.getMessage().contains("Array size can not be negative in
function:array_with_constant"))
+ assertTrue(ex.getMessage().contains("Array size should in range(0,
1000000) in function"))
}
+ // -- {server for large array}
+ try {
+ sql """
+ SELECT array_with_constant(1000001, 1);
+ """
+ } catch (Exception ex) {
+ assertTrue(ex.getMessage().contains("Array size should in range(0,
1000000) in function"))
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]