Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support cross-shard avg #9397

Closed
TDavid2509 opened this issue Dec 16, 2021 · 0 comments · Fixed by #14419
Closed

support cross-shard avg #9397

TDavid2509 opened this issue Dec 16, 2021 · 0 comments · Fixed by #14419

Comments

@TDavid2509
Copy link

Hi Vitess developers,

I have question about SQL plan/engine. Do u have any plan about supportting cross-shards avg function? From my perspective, this is similar to the distinct_count or distinct_sum.

Feature Description

If there is a cross shards SQL:

SELECT user.name, avg(user.age) FROM user GROUP BY user.name

we can modify it into Route as:

SELECT user.name, sum(user.age), count(user.age) FROM user GROUP BY user.name ORDER BY user.name

And the OrderedAggregate can compute avg value by utilizing the ordered result from Route, which is similar to the distinct_count.

Use Case(s)

SELECT user.name, avg(user.age) FROM user GROUP BY user.name

My solution is just a discussion. I know there are some other challenges I haven't considered. If there are some incorrect points, pls figure them out.

thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants