Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix](func)fix array_with_const with larger than max_array_size #37495

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions be/src/vec/columns/column_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,6 @@ class SipHash;

namespace doris::vectorized {

namespace ErrorCodes {
extern const int NOT_IMPLEMENTED;
extern const int BAD_ARGUMENTS;
extern const int PARAMETER_OUT_OF_BOUND;
extern const int SIZES_OF_COLUMNS_DOESNT_MATCH;
extern const int LOGICAL_ERROR;
extern const int TOO_LARGE_ARRAY_SIZE;
} // namespace ErrorCodes

ColumnArray::ColumnArray(MutableColumnPtr&& nested_column, MutableColumnPtr&& offsets_column)
: data(std::move(nested_column)), offsets(std::move(offsets_column)) {
const auto* offsets_concrete = typeid_cast<const ColumnOffsets*>(offsets.get());
Expand Down
6 changes: 3 additions & 3 deletions be/src/vec/functions/array/function_array_with_constant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,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: {}",
amorynan marked this conversation as resolved.
Show resolved Hide resolved
max_array_size_as_field, get_name());
}
offset += array_size;
offsets.push_back(offset);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// under the License.

suite("test_array_functions_array_with_const", "p0") {
sql "set enable_nereids_planner=false;"
amorynan marked this conversation as resolved.
Show resolved Hide resolved
//array_with_constant
qt_old_sql "SELECT 'array_with_constant';"
order_qt_old_sql "SELECT array_with_constant(3, number) FROM numbers limit 10;"
Expand All @@ -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 {
amorynan marked this conversation as resolved.
Show resolved Hide resolved
sql """
SELECT array_with_constant(1000001, 1);
"""
} catch (Exception ex) {
assertTrue(ex.getMessage().contains("Array size should in range(0, 1000000) in function"))
}


Expand All @@ -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"))
}
}
Loading