You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "morrySnow (via GitHub)" <gi...@apache.org> on 2024/07/02 16:58:34 UTC
[I] [Enhancement] support distinct in analytic functions [doris]
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: commits-unsubscribe@doris.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [I] [Enhancement] support distinct in analytic functions [doris]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #36878:
URL: https://github.com/apache/doris/issues/36878#issuecomment-3283052630
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!
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [I] [Enhancement] support distinct in analytic functions [doris]
Posted by "cjj2010 (via GitHub)" <gi...@apache.org>.
cjj2010 commented on issue #36878:
URL: https://github.com/apache/doris/issues/36878#issuecomment-2197872071
> @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
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [I] [Enhancement] support distinct in analytic functions [doris]
Posted by "morningman (via GitHub)" <gi...@apache.org>.
morningman closed issue #36878: [Enhancement] support distinct in analytic functions
URL: https://github.com/apache/doris/issues/36878
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org