github-actions[bot] commented on code in PR #66159:
URL: https://github.com/apache/doris/pull/66159#discussion_r3837022639
##########
be/src/exprs/function/array/function_array_map.h:
##########
@@ -191,6 +198,81 @@ struct ArrayMapImpl {
return true;
}
+ static bool _execute_nested_array(ColumnArrayMutableData& dst,
+ const ColumnArrayExecutionDatas& datas,
+ const std::vector<bool>& col_const,
size_t start_row,
+ size_t end_row) {
+ for (const auto& data : datas) {
+ if (!is_column<ColumnArray>(*data.nested_col)) {
+ return false;
+ }
+ }
+
+ size_t result_offset = 0;
+ for (size_t row = start_row; row < end_row; ++row) {
+ bool has_null = false;
+ for (size_t arg_idx = 0; arg_idx < datas.size() && !has_null;
++arg_idx) {
+ const auto& data = datas[arg_idx];
+ const size_t input_row = index_check_const(row,
col_const[arg_idx]);
+ const size_t begin = (*data.offsets_ptr)[input_row - 1];
+ const size_t end = (*data.offsets_ptr)[input_row];
+
+ for (size_t off = begin; off < end; ++off) {
+ if (data.nested_nullmap_data &&
data.nested_nullmap_data[off]) {
+ has_null = true;
+ break;
+ }
+ }
+ }
+
+ const size_t row_result_begin = result_offset;
+ if (has_null) {
+ dst.nested_col->insert_default();
+ if (dst.nested_nullmap_data) {
+ dst.nested_nullmap_data->push_back(1);
+ }
+ ++result_offset;
+ }
+
+ for (size_t arg_idx = 0; arg_idx < datas.size(); ++arg_idx) {
+ const auto& data = datas[arg_idx];
+ const size_t input_row = index_check_const(row,
col_const[arg_idx]);
+ const size_t begin = (*data.offsets_ptr)[input_row - 1];
+ const size_t end = (*data.offsets_ptr)[input_row];
+
+ for (size_t off = begin; off < end; ++off) {
+ if (data.nested_nullmap_data &&
data.nested_nullmap_data[off]) {
+ continue;
+ }
+
+ bool duplicated = false;
+ for (size_t result_pos = row_result_begin; result_pos <
result_offset;
Review Comment:
Please avoid the quadratic prior-result scan here. A legal input such as
`array_union(array_map(x -> array_range(x, x + 1), array_range(1, 100001)),
[])` contains 100,000 distinct inner arrays, so this loop performs
`N(N-1)/2`—about five billion—`ColumnArray::compare_at` calls for one row;
shared inner prefixes multiply that work. The previous byte-key path needed
value-semantic equality, but a full scan per element makes the newly supported
path unusable at allowed cardinalities. Use a value-semantic fingerprint/index
that canonicalizes `+0.0/-0.0` and NaNs, with `compare_at` for collision
checks, and add distinct-heavy coverage.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]