Github user marmbrus commented on the pull request: https://github.com/apache/spark/pull/4764#issuecomment-91089650 Thanks for working ont his and sorry for the delay in reviewing it. My high level feedback is that I think we should optimize handling of distinct aggregation, but there are already plans to do this more holistically instead of as a point solution. If this is really important to you for some specific production workload, we could consider adding something simple now and removing it later, but otherwise I'd prefer to wait for the full solution. More specifically, I have some advice on how I would structure this if we were to move forward with this approach. - Code style: In general for the whole optimizer we try to avoid the use of `var`s and `while` loops, preferring functional constructs where possible. `var`s and `while` loops are okay in performance critical code. - Placement: Instead of making changes to analysis (only resolution and type coercion should happen here) and planning, I think this should be a single rule inside of the Optimizer. This is because it starts with a valid logical plan and ends with a valid logical plan, but is rewriting it to be more efficient. - SumZero: Where possible, prefer to compose existing constructs. i.e., I think this could just be a `coalesce(sum(...), 0)` instead of duplicating a significant amount of code.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org