From 98d4e700e19d1dec2a20b33c4284dacbf09dde83 Mon Sep 17 00:00:00 2001 From: amorynan Date: Fri, 19 Jul 2024 17:54:17 +0800 Subject: [PATCH 1/2] fix array with const constructor --- be/src/vec/functions/array/function_array_with_constant.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 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 9e3885b1c3cf5a..8ef226903138af 100644 --- a/be/src/vec/functions/array/function_array_with_constant.cpp +++ b/be/src/vec/functions/array/function_array_with_constant.cpp @@ -92,9 +92,9 @@ class FunctionArrayWithConstant : public IFunction { 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); From cb1808a3924f62b57926e08509bb31647acff685 Mon Sep 17 00:00:00 2001 From: amorynan Date: Thu, 25 Jul 2024 15:16:11 +0800 Subject: [PATCH 2/2] format it --- be/src/vec/functions/array/function_array_with_constant.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 8ef226903138af..724f3cc1316ee6 100644 --- a/be/src/vec/functions/array/function_array_with_constant.cpp +++ b/be/src/vec/functions/array/function_array_with_constant.cpp @@ -92,7 +92,7 @@ class FunctionArrayWithConstant : public IFunction { 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) || UNLIKELY(array_size > max_array_size_as_field)) { + 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()); }