ydgandhi opened a new issue, #21087: URL: https://github.com/apache/datafusion/issues/21087
### Is your feature request related to a problem or challenge? DataFusion's default execution creates separate HashSet accumulators for each distinct count per group. With high-cardinality data (eg sellers with 4,000+ distinct cities in an ecommerce dataset), this causes memory explosion. ### Describe the solution you'd like DataFusion already optimizes the single shared distinct field case via SingleDistinctToGroupBy. This PR adds a conservative logical rewrite for multiple distinct COUNT(DISTINCT …) arguments by splitting work into per-distinct branches joined on the group keys, which reduces peak memory for eligible plans. COUNT(DISTINCT x) must ignore NULL x; the rewrite applies x IS NOT NULL on each distinct branch before inner grouping so semantics stay aligned with count_distinct behavior. ### 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]
