feiniaofeiafei opened a new pull request, #65664:
URL: https://github.com/apache/doris/pull/65664
### What problem does this PR solve?
Issue Number: N/A
Related PR: N/A
Problem Summary:
Nereids could select the multi-distinct execution strategy for aggregate
functions that do not implement `SupportMultiDistinct`. Queries containing
multiple DISTINCT argument groups could therefore fail or be planned with an
unsupported strategy.
This change detects all DISTINCT aggregate functions that cannot use the
multi-distinct implementation and forces the CTE split strategy for those
queries. It also corrects DISTINCT argument extraction for aggregates with
control parameters, so only the value argument participates in deduplication;
for example, `topn(DISTINCT value, n)` should deduplicate `value`, not the
constant `n`.
`NormalizeAggregate` now recognizes all constant expressions instead of only
literal nodes, preventing constant aggregate parameters from being incorrectly
pushed into the deduplication projection.
Additionally, `map_agg_v1` and `map_agg_v2` expose their DISTINCT
constructors to the built-in function registry. This fixes binding of
`map_agg(DISTINCT key, value)`, which previously failed with an incorrect
three-argument arity error.
Regression coverage is added for supported DISTINCT aggregate functions in
both scalar and grouped aggregation, including queries with two different
DISTINCT argument groups. MAP results are normalized into sorted key/value
arrays where applicable to avoid nondeterministic MAP serialization order.
### Release note
Nereids now supports more queries containing multiple DISTINCT aggregate
functions by using CTE split when multi-distinct execution is unsupported.
`map_agg(DISTINCT key, value)` is supported.
### Check List (For Author)
- Test: Regression test
- `./run-regression-test.sh --run -d nereids_function_p0 -s
agg_distinct_function -forceGenOut`
- Behavior changed: Yes. More DISTINCT aggregate queries can be planned and
executed; `map_agg(DISTINCT ...)` now binds successfully.
- Does this need documentation: No
--
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]