jd-opensource/vtdriver

support cross-shards avg

Closed this issue · 0 comments

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