Helllo friends ,
I have the following function signature
def groupAndAggregate(inputDS: Dataset[Row], aggregateFunMap: Map[String, String], aggregateColumns: List[String]):Dataset[Row]={
// statements
}
Where aggregateFunMap is a Map contains columns as key and corresponding aggregate operation to be performed
Eg :- val aggregateFunMap=Map("amount"->"avg","amount"->"sum")
And , aggregateColumns
is a List which contains columns that is used to group by operation
Eg:- val aggregateColumns=List("amount")
I have the following code to find the final result after performing the group by operation and the aggregation .
{
val grouped = inputDS.groupBy(aggregateColumns.head, aggregateColumns.tail: _*)
grouped.agg(aggregateFunMap)
}
But when i passed Map with multiple aggregation operations on the same column it returns an incorrect result ie ; the final dataframe contains only one aggregation operation .
If some one can help me , it will be great help for me .