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: [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]