morrySnow opened a new issue, #36878:
URL: https://github.com/apache/doris/issues/36878

   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no 
similar issues.
   
   
   ### Description
   
   ```sql
   create table t(id int, c1 int, c2 double, c3 string) 
properties('replication_num'='1');
   ```
   
   support distinct in analytic functions: count, sum and avg
   
   ```sql
   select c1, c2, avg( distinct c1) over(partition by c2) from t;
   ```
   
   ### Solution
   
   1. 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
   3. convert functions to distinct one in 
[`ExtractAndNormalizeWindowExpression`](https://github.com/apache/doris/blob/4e1dbb0a9e70ae72e0c8998a83ed18349500099c/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/ExtractAndNormalizeWindowExpression.java)
     2.1. `count(distinct c1) over(partition c2)` to `multi_distinct_count(c1) 
over(partition c2)` 
     2.2. `sum(distinct c1) over(partition c2)` to `multi_distinct_sum(c1) 
over(partition c2)` 
     2.3. `avg(distinct c1) over(partition c2)` to `cast(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](https://www.apache.org/foundation/policies/conduct)
   


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

Reply via email to