SPARK-1627: Support external aggregation by using Aggregator in Spark SQL