Baymine opened a new pull request, #65245:
URL: https://github.com/apache/doris/pull/65245
### What problem does this PR solve?
Issue Number: close #65244
Problem Summary:
When a single GROUP BY contained more than one DISTINCT aggregate and any of
them was collect_list(distinct ...) or array_agg(distinct ...), planning
failed
with "... can't support multi distinct". CheckMultiDistinct rejects any
distinct
aggregate that is not a SupportMultiDistinct, and collect_list / array_agg
did
not implement that interface, so queries such as
select g, collect_list(distinct a), collect_list(distinct b) from t
group by g
select g, array_agg(distinct a), array_agg(distinct b) from t group by g
could not run at all.
This adds the missing multi-distinct variants and wires them into the
existing
framework:
- FE: CollectList and ArrayAgg now implement SupportMultiDistinct and
convert to
the new MultiDistinctCollectList / MultiDistinctArrayAgg functions. The new
functions implement MultiDistinction, are registered in
BuiltinAggregateFunctions, and get visitor hooks in
AggregateFunctionVisitor.
- BE: registers multi_distinct_collect_list and multi_distinct_array_agg.
Both
dedup in the aggregate state via the existing Set-backed collect data,
because
the Nereids multi-distinct plan does not push the distinct argument into
the
group-by key.
### Release note
Support multiple DISTINCT aggregates in one GROUP BY when they include
collect_list(distinct ...) or array_agg(distinct ...).
### Check List (For Author)
- Test:
- [x] Unit Test: MultiDistinctArrayAggTest,
MultiDistinctCollectListTest, CheckMultiDistinctTest (28 cases, all pass).
- [x] Regression test: added
regression-test/suites/nereids_p0/multi_distinct/multi_distinct_collect_list.groovy
(runs in CI).
- Behavior changed:
- [x] Yes. Queries that previously failed with "can't support multi
distinct" for collect_list/array_agg now plan and run.
- Does this need documentation?
- [x] 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]