Spark Sql Aggregate Function