[Enhancement] support distinct in analytic functions
Search before asking
- [X] I had searched in the issues and found no similar issues.
Description
create table t(id int, c1 int, c2 double, c3 string) properties('replication_num'='1');
support distinct in analytic functions: count, sum and avg
select c1, c2, avg( distinct c1) over(partition by c2) from t;
Solution
- remove restirct of distinct in analytic functions 1.1. https://github.com/apache/doris/blob/543576227db1521e66c2d32a6fa522c1a7a7aa61/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java#L2140-L2145 1.2. https://github.com/apache/doris/blob/543576227db1521e66c2d32a6fa522c1a7a7aa61/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java#L2155-L2160
- convert functions to distinct one in
ExtractAndNormalizeWindowExpression2.1.count(distinct c1) over(partition c2)tomulti_distinct_count(c1) over(partition c2)2.2.sum(distinct c1) over(partition c2)tomulti_distinct_sum(c1) over(partition c2)2.3.avg(distinct c1) over(partition c2)tocast(multi_distinct_sum(c1) over(partition c2) as double) / cast(multi_distinct_count(c1) over(partition c2) as double)
Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
I want to try 2.1
@cjj2010 This issue cannot be split into smaller tasks for solving. Can you handle the entire issue?
@cjj2010 This issue cannot be split into smaller tasks for solving. Can you handle the entire issue?
Okay, I am willing to handle the entire issue. The business scenario I am currently facing requires this feature very much
@cjj2010 Great! I will assign this issue to you
We're closing this issue because it hasn't been updated in a while. If you'd like to revive this issue, please reopen it and feel free a maintainer to remove the Stale tag!