haohuaijin opened a new issue, #19638: URL: https://github.com/apache/datafusion/issues/19638
### Is your feature request related to a problem or challenge? current the `GroupedTopKAggregateStream` support two type of query ```sql select id, max(time) from t group by id order by max(time) desc limit 10 select id, min(time) from t group by id order by min(time) asc limit 10 ``` we have another use case that i find it also can use GroupedTopKAggregateStream to spped up, like below query ```sql select distinct id from t order by id desc/asc limit 10 select id from t group by id order by id desc/asc limit 10 ``` because If a certain `id = x` is in the global top 10(the second phase of AggregateExec), then `x` must appear in the local top 10(the first phase of AggregateExec) of at least one partition. ### Describe the solution you'd like 1. modify the `TopKAggregation` optimizer rule to pass the information to AggregateExec 2. modify `GroupedTopKAggregateStream` to support this case ### Describe alternatives you've considered _No response_ ### Additional context _No response_ -- 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]
