Description
In `aggregate/utils.scala`, there is a substantial amount of duplication in the expression-rewriting logic. As a prerequisite to supporting imperative aggregate functions in `TungstenAggregate`, we should refactor this file so that the same expression-rewriting logic is used for both `SortAggregate` and `TungstenAggregate`.