github-actions[bot] commented on code in PR #62520:
URL: https://github.com/apache/doris/pull/62520#discussion_r3092530406
##########
fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinAggregateFunctions.java:
##########
@@ -173,11 +175,13 @@ private BuiltinAggregateFunctions() {
agg(OrthogonalBitmapIntersect.class,
"orthogonal_bitmap_intersect"),
agg(OrthogonalBitmapIntersectCount.class,
"orthogonal_bitmap_intersect_count"),
agg(OrthogonalBitmapUnionCount.class,
"orthogonal_bitmap_union_count"),
Review Comment:
Once `percentile` / `percentile_cont` bind to `PercentileV2` here, the main
optimization path stops triggering: `MergePercentileToArray.collectFuncMap()`
still only matches the v1 `Percentile` class. So `select percentile(x, 0.1),
percentile(x, 0.2) ...` (and the `median()` rewrite, which now also produces
`PercentileV2`) no longer merge into a single `percentile_array_v2(...)` state,
which defeats the main performance goal of this PR for the default Nereids path.
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/MergePercentileToArray.java:
##########
@@ -96,14 +96,14 @@ private List<AggregateFunction>
getPercentileArrays(Map<DistinctAndExpr, List<Ag
percentArray = new Array(percentList.toArray(new
Expression[0]));
}
- PercentileArray percentileArray;
Expression secondArg = allPercentIsLiteral
? TypeCoercionUtils.castIfNotSameType(percentArrayLiteral,
ArrayType.of(DoubleType.INSTANCE))
: TypeCoercionUtils.castIfNotSameType(percentArray,
ArrayType.of(DoubleType.INSTANCE));
+ AggregateFunction percentileArray;
if (entry.getKey().isDistinct) {
Review Comment:
`collectFuncMap()` still only collects `Percentile`, which after this PR is
the explicit `percentile_v1` class. Replacing those functions with
`PercentileArrayV2` changes semantics: `select percentile_v1(x, 0.1),
percentile_v1(x, 0.9) ...` will now be planned as `percentile_array_v2(...)`,
so the result no longer matches the explicit compatibility function the user
asked for. The merged aggregate needs to stay on the v1 implementation when the
collected functions are `Percentile`.
##########
be/src/exprs/aggregate/aggregate_function_percentile.cpp:
##########
@@ -74,8 +83,16 @@ void
register_percentile_approx_old_function(AggregateFunctionSimpleFactory& fac
}
void
register_aggregate_function_percentile_old(AggregateFunctionSimpleFactory&
factory) {
-
BeExecVersionManager::registe_restrict_function_compatibility("percentile");
-
BeExecVersionManager::registe_restrict_function_compatibility("percentile_array");
+ using creator = creator_with_type_list<TYPE_TINYINT, TYPE_SMALLINT,
TYPE_INT, TYPE_BIGINT,
+ TYPE_LARGEINT, TYPE_FLOAT,
TYPE_DOUBLE>;
+ factory.register_alternative_function("percentile",
Review Comment:
The old-version registration here only covers `percentile` /
`percentile_array`. After the FE changes in this PR, Nereids serializes the
default spellings as `percentile_v2` / `percentile_array_v2`
(`ExpressionTranslator.visitAggregateFunction()` uses `function.getName()`), so
`be_exec_version=6` no longer forces the old implementation for ordinary
`percentile(...)` queries. That breaks the rolling-upgrade compatibility story
for the default path.
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/types/AggStateType.java:
##########
@@ -49,7 +49,9 @@ public class AggStateType extends DataType {
.put("any", "any_value")
.put("char_length", "character_length")
.put("stddev_pop", "stddev")
- .put("percentile_cont", "percentile")
+ .put("percentile_cont", "percentile_v2")
+ .put("percentile", "percentile_v2")
Review Comment:
Canonicalizing existing `agg_state` names from `percentile` /
`percentile_array` to the v2 names here breaks stored percentile states.
`DataType.fromCatalogType()` reconstructs catalog `AggStateType`s through this
constructor, and `PlanTranslatorContext` later re-emits that normalized type to
BE. For an old `agg_state<percentile(...)>` column or MV, BE union/merge will
deserialize persisted v1 bytes with the v2 nested aggregate function, bypassing
the old `be_exec_version` compatibility 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: [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]