You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "Mryange (via GitHub)" <gi...@apache.org> on 2026/04/23 06:46:33 UTC
[PR] [opt](agg) use binary serde for collect_list/collect_set on complex types [doris]
Mryange opened a new pull request, #62743:
URL: https://github.com/apache/doris/pull/62743
## What problem does this PR solve?
`collect_list` and `collect_set` aggregate functions use JSON text serialization (`serialize_one_cell_to_json` / `deserialize_one_cell_from_json`) when handling complex or arbitrary-typed input columns (the `INVALID_TYPE` specialization). JSON serde is significantly slower than binary serde and can introduce precision/correctness issues for certain types (e.g., large integers, nested structures).
This PR introduces `collect_list_v2` / `collect_set_v2` using the binary IColumn API (`serialize_value_into_arena` / `deserialize_and_insert_from_arena`) for all types that fall into the generic path, following the same v1/v2 upgrade-compatibility pattern used by `map_agg` → `map_agg_v2`.
## Changes
**BE:**
- `aggregate_function_collect.h`: Add `AggregateFunctionCollectListDataV2` struct that uses binary serde via `IColumn::serialize_value_into_arena` / `deserialize_and_insert_from_arena`. Add `IsV2` template parameter to `AggregateFunctionCollect`.
- `aggregate_function_collect.cpp`: Register `collect_list_v1` / `collect_set_v1` as aliases for backward compatibility (old serialized states remain readable).
- `aggregate_function_collect_impl_v2.h` / `aggregate_function_collect_v2*.cpp`: New registration entry point for `collect_list_v2` and `collect_set_v2`.
- `aggregate_function_simple_factory.cpp`: Call `register_aggregate_function_collect_list_v2`.
**FE:**
- `CollectListV2.java` / `CollectSetV2.java`: New Nereids function classes bound to `collect_list_v2` / `collect_set_v2`.
- `BuiltinAggregateFunctions.java`: Map user-facing `collect_list` / `group_array` to `CollectListV2` (v2 as default); keep `CollectList` registered as `collect_list_v1` for upgrade compatibility.
## Upgrade compatibility
| Scenario | Behavior |
|---|---|
| Rolling upgrade (old BE + new FE) | FE routes to `collect_list_v1`; old BE handles it with JSON serde as before |
| New BE + new FE | FE routes to `collect_list_v2`; BE uses binary serde |
| Mixed cluster mid-upgrade | `collect_list_v1` alias on new BE falls back to JSON serde path |
### Release note
None
### Check List (For Author)
- Test <!-- At least one of them must be included. -->
- [ ] Regression test
- [ ] Unit Test
- [ ] Manual test (add detailed scripts or steps below)
- [ ] No need to test or manual test. Explain why:
- [ ] This is a refactor/code format and no logic has been changed.
- [ ] Previous test can cover this change.
- [ ] No code files have been changed.
- [ ] Other reason <!-- Add your reason? -->
- Behavior changed:
- [ ] No.
- [ ] Yes. <!-- Explain the behavior change -->
- Does this need documentation?
- [ ] No.
- [ ] Yes. <!-- Add document PR link here. eg: https://github.com/apache/doris-website/pull/1214 -->
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR should merge into -->
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [opt](agg) use binary serde for collect_list/collect_set on complex types [doris]
Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #62743:
URL: https://github.com/apache/doris/pull/62743#issuecomment-4310407524
# BE Regression && UT Coverage Report
Increment line coverage `42.29% (74/175)` :tada:
[Increment coverage report](http://coverage.selectdb-in.cc/coverage/62743_85d2da26cf7ca66e92e2bd0f3f3722460a5534a0_merge/increment_report/index.html)
[Complete coverage report](http://coverage.selectdb-in.cc/coverage/62743_85d2da26cf7ca66e92e2bd0f3f3722460a5534a0_merge/report/index.html)
| Category | Coverage |
|-------------------|--------------------|
| Function Coverage | 71.39% (26740/37454) |
| Line Coverage | 53.75% (279242/519507) |
| Region Coverage | 47.11% (214586/455525) |
| Branch Coverage | 50.41% (97137/192702) |
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [opt](agg) use binary serde for collect_list/collect_set on complex types [doris]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on code in PR #62743:
URL: https://github.com/apache/doris/pull/62743#discussion_r3130021828
##########
be/test/exprs/function/varray_match_function_test.cpp:
##########
@@ -0,0 +1,211 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include <gtest/gtest.h>
+
+#include <memory>
+#include <string>
+
+#include "core/block/block.h"
+#include "core/column/column_array.h"
+#include "core/column/column_const.h"
+#include "core/column/column_nullable.h"
+#include "core/column/column_vector.h"
+#include "core/data_type/data_type_array.h"
+#include "core/data_type/data_type_nullable.h"
+#include "core/data_type/data_type_number.h"
+#include "exprs/function/function_test_util.h"
+#include "exprs/function/simple_function_factory.h"
+
+namespace doris {
+
+// -----------------------------------------------------------------------
+// Helper: build a ColumnArray<Nullable<Boolean>> from a flat bool list.
+// offsets[i] is the end of row i's elements.
+// -----------------------------------------------------------------------
+static ColumnPtr make_bool_array_column(const std::vector<std::vector<uint8_t>>& rows) {
+ // nested: Nullable<UInt8>
+ auto nested_data = ColumnUInt8::create();
+ auto nested_null = ColumnUInt8::create();
+ ColumnArray::Offsets64 offsets;
+ uint64_t total = 0;
+ for (const auto& row : rows) {
+ for (uint8_t v : row) {
+ nested_data->insert_value(v);
+ nested_null->insert_value(0);
+ }
+ total += row.size();
+ offsets.push_back(total);
+ }
+ auto nullable_nested =
+ ColumnNullable::create(std::move(nested_data), std::move(nested_null));
+ auto offsets_col = ColumnArray::ColumnOffsets::create();
+ offsets_col->get_data() = std::move(offsets);
+ return ColumnArray::create(std::move(nullable_nested), std::move(offsets_col));
+}
+
+// Return type: Nullable<UInt8>
+static DataTypePtr make_return_type() {
+ return make_nullable(std::make_shared<DataTypeUInt8>());
+}
+
+// Build a FunctionBasePtr for array_match_all / array_match_any.
+static FunctionBasePtr get_fn(const std::string& func_name, const DataTypePtr& input_type) {
+ ColumnsWithTypeAndName args = {{nullptr, input_type, "arg0"}};
+ return SimpleFunctionFactory::instance().get_function(func_name, args, make_return_type());
+}
+
+// Execute func with a single column block and return the result column.
+static ColumnPtr execute_fn(const std::string& func_name, const DataTypePtr& input_type,
+ ColumnPtr col, size_t rows) {
+ Block block;
+ block.insert({col, input_type, "arg0"});
+ block.insert({nullptr, make_return_type(), "result"});
+
+ auto func = get_fn(func_name, input_type);
+ EXPECT_NE(func, nullptr);
+
+ FunctionUtils fn_utils(make_return_type(), {input_type}, false);
+ auto* ctx = fn_utils.get_fn_ctx();
+ ctx->set_constant_cols({nullptr});
+ EXPECT_EQ(func->open(ctx, FunctionContext::FRAGMENT_LOCAL), Status::OK());
+ EXPECT_EQ(func->open(ctx, FunctionContext::THREAD_LOCAL), Status::OK());
+
+ ColumnNumbers args_idx = {0};
+ EXPECT_EQ(func->execute(ctx, block, args_idx, 1, rows), Status::OK());
+
+ EXPECT_EQ(func->close(ctx, FunctionContext::THREAD_LOCAL), Status::OK());
+ EXPECT_EQ(func->close(ctx, FunctionContext::FRAGMENT_LOCAL), Status::OK());
+ return block.get_by_position(1).column;
+}
+
+// -----------------------------------------------------------------------
+// 1. Basic correctness: non-const input
+// -----------------------------------------------------------------------
+TEST(ArrayMatchFunctionTest, basic_correctness_check_function) {
+ // array_match_all(Array<Nullable<Boolean>>)
+ {
+ std::string func_name = "array_match_all";
+ InputTypeSet input_types = {PrimitiveType::TYPE_ARRAY, PrimitiveType::TYPE_NULL,
+ PrimitiveType::TYPE_BOOLEAN};
+ TestArray all_true = {UInt8(1), UInt8(1)};
+ TestArray has_false = {UInt8(1), UInt8(0)};
+ TestArray with_null = {UInt8(1), Null()};
+ TestArray all_null = {Null(), Null()};
+ TestArray empty_arr;
+ DataSet data_set = {
+ {{AnyType(all_true)}, UInt8(1)}, // all true -> true
+ {{AnyType(has_false)}, UInt8(0)}, // has false -> false
+ {{AnyType(with_null)}, Null()}, // has null, rest true -> null
+ {{AnyType(all_null)}, Null()}, // all null -> null
+ {{AnyType(empty_arr)}, UInt8(1)}, // empty -> true (vacuous)
+ };
+ static_cast<void>(
+ check_function<DataTypeUInt8, true>(func_name, input_types, data_set));
+ }
+
+ // array_match_any(Array<Nullable<Boolean>>)
+ {
+ std::string func_name = "array_match_any";
+ InputTypeSet input_types = {PrimitiveType::TYPE_ARRAY, PrimitiveType::TYPE_NULL,
+ PrimitiveType::TYPE_BOOLEAN};
+ TestArray all_false = {UInt8(0), UInt8(0)};
+ TestArray has_true = {UInt8(0), UInt8(1)};
+ TestArray with_null = {UInt8(0), Null()};
+ TestArray empty_arr;
+ DataSet data_set = {
+ {{AnyType(all_false)}, UInt8(0)}, // all false -> false
+ {{AnyType(has_true)}, UInt8(1)}, // has true -> true
+ {{AnyType(with_null)}, Null()}, // has null, rest false -> null
+ {{AnyType(empty_arr)}, UInt8(0)}, // empty -> false (vacuous)
+ };
+ static_cast<void>(
+ check_function<DataTypeUInt8, true>(func_name, input_types, data_set));
+ }
+}
+
+// -----------------------------------------------------------------------
+// 2. Const-column input: the execution framework wraps the result in
+// ColumnConst because use_default_implementation_for_constants()=true.
+// Verify results are correct and result is ColumnConst.
+// -----------------------------------------------------------------------
+TEST(ArrayMatchFunctionTest, const_column_input_result_is_column_const) {
+ // Input type: Nullable<Array<Nullable<Boolean>>>
+ auto inner_bool_type = make_nullable(std::make_shared<DataTypeUInt8>());
+ auto array_type = make_nullable(std::make_shared<DataTypeArray>(inner_bool_type));
+
+ const size_t N = 5; // number of rows in the block
+
+ for (const std::string& func_name : {"array_match_all", "array_match_any"}) {
+ // Build a 1-element ColumnArray: [[true, true]]
+ auto inner_col = make_bool_array_column({{1, 1}});
+ // Wrap it in Nullable (not null at the outer level)
+ auto null_map = ColumnUInt8::create(1, 0);
+ auto nullable_col = ColumnNullable::create(inner_col, std::move(null_map));
+
+ // Create ColumnConst: same array repeated N times
+ auto const_col = ColumnConst::create(std::move(nullable_col), N);
+
+ auto result = execute_fn(func_name, array_type, std::move(const_col), N);
+ ASSERT_TRUE(result.get() != nullptr) << func_name;
+
+ // The result MUST be ColumnConst when all inputs are const
+ // (guaranteed by use_default_implementation_for_constants()=true)
+ EXPECT_TRUE(is_column_const(*result))
+ << func_name
+ << ": result should be ColumnConst when input is all-const, but got size="
+ << result->size();
+
+ // And must have size N
+ EXPECT_EQ(result->size(), N) << func_name;
+ }
+}
+
+// -----------------------------------------------------------------------
+// 3. BUG REPRODUCTION:
+// is_use_default_implementation_for_constants() currently returns false.
+// This causes VectorizedFnCall::is_constant() to return false even when
+// all children are const, so the expression cannot be const-folded at the
+// VExpr planning level.
+//
+// The correct value should be true (delegate to
+// use_default_implementation_for_constants() which is true by default).
+//
+// This test FAILS with the current code and will PASS after the fix
+// (removing the is_use_default_implementation_for_constants()=false override).
+// -----------------------------------------------------------------------
+TEST(ArrayMatchFunctionTest, is_use_default_implementation_for_constants_should_be_true) {
+ auto inner_bool_type = make_nullable(std::make_shared<DataTypeUInt8>());
+ auto array_type = make_nullable(std::make_shared<DataTypeArray>(inner_bool_type));
+ ColumnsWithTypeAndName args = {{nullptr, array_type, "arg0"}};
+
+ for (const std::string& func_name : {"array_match_all", "array_match_any"}) {
+ auto func = SimpleFunctionFactory::instance().get_function(func_name, args,
+ make_return_type());
+ ASSERT_NE(func, nullptr) << func_name;
+
+ // This assertion currently FAILS because the function overrides
+ // is_use_default_implementation_for_constants() to return false,
+ // breaking VExpr-level const-folding for all-const inputs.
+ EXPECT_TRUE(func->is_use_default_implementation_for_constants())
Review Comment:
This PR does not change `array_match_*`, but `be/test/CMakeLists.txt` picks up every `*.cpp` under `be/test/`, so this file becomes part of normal BE UT. The assertion here is currently false in checked-in code: `ArrayMatchFunction::is_use_default_implementation_for_constants()` explicitly returns `false` in `be/src/exprs/function/array/varray_match_function.cpp:50`, and `DefaultFunction` forwards that value unchanged. As written, the PR adds a deterministic BE unit-test failure unrelated to the `collect_*` change. If the array-match fix is intentional, the implementation change needs to be included here. Otherwise this test file should be dropped.
##########
be/src/exprs/aggregate/aggregate_function_collect_impl_v2.h:
##########
@@ -0,0 +1,82 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include "common/exception.h"
+#include "common/status.h"
+#include "core/call_on_type_index.h"
+#include "exprs/aggregate/aggregate_function_collect.h"
+#include "exprs/aggregate/factory_helpers.h"
+#include "exprs/aggregate/helpers.h"
+
+namespace doris {
+
+// For collect_list_v2: complex types use V2 binary serialization; simple/string types
+// use the same data structs as v1 (their serialization is already efficient binary).
+template <PrimitiveType T, bool HasLimit>
+AggregateFunctionPtr do_create_agg_function_collect_v2(bool distinct,
+ const DataTypes& argument_types,
+ const bool result_is_nullable,
+ const AggregateFunctionAttr& attr) {
+ if (distinct) {
+ if constexpr (T == INVALID_TYPE) {
+ throw Exception(ErrorCode::INTERNAL_ERROR,
Review Comment:
`collect_set` now binds to `collect_set_v2` in FE for the same `AnyDataType` signature as before, but this `INVALID_TYPE` branch still throws on every complex input. A query like `SELECT collect_set(km) FROM test_array_agg_complex` where `km` is MAP, ARRAY, or STRUCT will reach this path and fail with `unexpected type for collect_set_v2`, so the `collect_set` half of the advertised complex-type binary-serde feature is still missing. Either keep routing complex inputs to `collect_set_v1` or add a V2 distinct implementation and coverage for the `INVALID_TYPE` path.
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [opt](agg) use binary serde for collect_list/collect_set on complex types [doris]
Posted by "Mryange (via GitHub)" <gi...@apache.org>.
Mryange commented on PR #62743:
URL: https://github.com/apache/doris/pull/62743#issuecomment-4303317132
/review
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [opt](agg) use binary serde for collect_list/collect_set on complex types [doris]
Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #62743:
URL: https://github.com/apache/doris/pull/62743#issuecomment-4310427807
# FE Regression Coverage Report
Increment line coverage ` 37.78% (34/90)` :tada:
[Increment coverage report](http://coverage.selectdb-in.cc/coverage/62743_85d2da26cf7ca66e92e2bd0f3f3722460a5534a0_merge_fe/increment_report/index.html)
[Complete coverage report](http://coverage.selectdb-in.cc/coverage/62743_85d2da26cf7ca66e92e2bd0f3f3722460a5534a0_merge_fe/report/index.html)
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [opt](agg) use binary serde for collect_list/collect_set on complex types [doris]
Posted by "Mryange (via GitHub)" <gi...@apache.org>.
Mryange closed pull request #62743: [opt](agg) use binary serde for collect_list/collect_set on complex types
URL: https://github.com/apache/doris/pull/62743
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [opt](agg) use binary serde for collect_list/collect_set on complex types [doris]
Posted by "Mryange (via GitHub)" <gi...@apache.org>.
Mryange commented on PR #62743:
URL: https://github.com/apache/doris/pull/62743#issuecomment-4309593518
run buildall
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [opt](agg) use binary serde for collect_list/collect_set on complex types [doris]
Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #62743:
URL: https://github.com/apache/doris/pull/62743#issuecomment-4309974190
# FE UT Coverage Report
Increment line coverage ` 12.00% (6/50)` :tada:
[Increment coverage report](http://coverage.selectdb-in.cc/coverage/62743_85d2da26cf7ca66e92e2bd0f3f3722460a5534a0/fe_increment_report/index.html)
[Complete coverage report](http://coverage.selectdb-in.cc/coverage/62743_85d2da26cf7ca66e92e2bd0f3f3722460a5534a0/fe_report/index.html)
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [opt](agg) use binary serde for collect_list/collect_set on complex types [doris]
Posted by "Mryange (via GitHub)" <gi...@apache.org>.
Mryange commented on PR #62743:
URL: https://github.com/apache/doris/pull/62743#issuecomment-4303848316
/review
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [opt](agg) use binary serde for collect_list/collect_set on complex types [doris]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on code in PR #62743:
URL: https://github.com/apache/doris/pull/62743#discussion_r3128941982
##########
be/src/exprs/aggregate/aggregate_function_collect.cpp:
##########
@@ -53,6 +53,9 @@ void register_aggregate_function_collect_list(AggregateFunctionSimpleFactory& fa
// notice: array_agg only differs from collect_list in that array_agg will show null elements in array
factory.register_function_both("collect_list", create_aggregate_function_collect);
factory.register_function_both("collect_set", create_aggregate_function_collect);
+ // v1 names: FE may send these after being upgraded while BEs are still upgrading
+ factory.register_function_both("collect_list_v1", create_aggregate_function_collect);
+ factory.register_function_both("collect_set_v1", create_aggregate_function_collect);
Review Comment:
`collect_set_v1` does not actually create a set aggregate here. `create_aggregate_function_collect_impl()` still uses `bool distinct = name == "collect_set";`, so this newly registered name goes down the `collect_list` branch and preserves duplicates. A concrete regression is the rollout path that is supposed to call `collect_set_v1`: on a new BE it will build list semantics instead of set semantics unless the helper also treats `collect_set_v1` as the distinct variant.
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/CollectListV2.java:
##########
@@ -0,0 +1,99 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.nereids.trees.expressions.functions.agg;
+
+import org.apache.doris.catalog.FunctionSignature;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
+import org.apache.doris.nereids.trees.expressions.literal.ArrayLiteral;
+import org.apache.doris.nereids.types.ArrayType;
+import org.apache.doris.nereids.types.IntegerType;
+import org.apache.doris.nereids.types.coercion.AnyDataType;
+import org.apache.doris.nereids.types.coercion.FollowToAnyDataType;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * AggregateFunction 'collect_list_v2'. This is the v2 version of collect_list, which uses
+ * binary serialization for complex types instead of JSON text, improving performance.
+ */
+public class CollectListV2 extends NotNullableAggregateFunction
+ implements ExplicitlyCastableSignature {
+
+ public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
+ FunctionSignature.ret(ArrayType.of(new FollowToAnyDataType(0))).args(new AnyDataType(0)),
+ FunctionSignature.ret(ArrayType.of(new FollowToAnyDataType(0)))
+ .args(new AnyDataType(0), IntegerType.INSTANCE)
+ );
+
+ /**
+ * constructor with 1 argument.
+ */
+ public CollectListV2(Expression arg) {
+ super("collect_list_v2", arg);
Review Comment:
Making the user-visible `collect_list` name resolve to `collect_list_v2` here is not enough for the rolling-upgrade story in the PR description. `ExpressionTranslator` / `FunctionToThriftConverter` serialize `function.getName()` verbatim, and I can't find the companion `BeExecVersionManager` compatibility registration on the BE side for `collect_list_v2` / `collect_set_v2`. That means FE with an old `be_exec_version` still sends `*_v2` to pre-change BEs, which only register `collect_list` / `collect_set` (plus the new `*_v1` aliases from this PR) and will fail function lookup.
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/CollectSetV2.java:
##########
@@ -0,0 +1,104 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.nereids.trees.expressions.functions.agg;
+
+import org.apache.doris.catalog.FunctionSignature;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
+import org.apache.doris.nereids.trees.expressions.literal.ArrayLiteral;
+import org.apache.doris.nereids.types.ArrayType;
+import org.apache.doris.nereids.types.IntegerType;
+import org.apache.doris.nereids.types.coercion.AnyDataType;
+import org.apache.doris.nereids.types.coercion.FollowToAnyDataType;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * AggregateFunction 'collect_set_v2'. This is the v2 version of collect_set.
+ */
+public class CollectSetV2 extends NotNullableAggregateFunction
+ implements ExplicitlyCastableSignature {
+
+ public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
+ FunctionSignature.ret(ArrayType.of(new FollowToAnyDataType(0))).args(new AnyDataType(0)),
+ FunctionSignature.ret(ArrayType.of(new FollowToAnyDataType(0)))
+ .args(new AnyDataType(0), IntegerType.INSTANCE)
+ );
+
+ /**
+ * constructor with 1 argument.
+ */
+ public CollectSetV2(Expression arg) {
+ super("collect_set_v2", arg);
Review Comment:
Changing the default nested function name to `collect_*_v2` also needs the same `AggStateType.aliasToName` update that `map_agg` and `window_funnel` already have. Right now `agg_state<collect_list(...)>` / `agg_state<collect_set(...)>` still canonicalize to `collect_list` / `collect_set`, while `collect_list_state` / `collect_set_state` and the corresponding `_merge` / `_union` combinators now build `*_v2` names. Those names are compared literally in FE agg-state cast checks and in BE `AggFnEvaluator`, so agg-state columns and combinators stop matching each other.
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [opt](agg) use binary serde for collect_list/collect_set on complex types [doris]
Posted by "Mryange (via GitHub)" <gi...@apache.org>.
Mryange commented on PR #62743:
URL: https://github.com/apache/doris/pull/62743#issuecomment-4302270530
/review
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org