Scala - 01 Aggregating Data (totals)

Hi,

While applying reduce() function for getting the revenue from order_items table, i am facing below error.I am using Spark 1.6.0 version. Please help in getting out of it. Thanks

val orderItemsReduce = orderItemsMap.reduce((acc, val) => acc + val)

Error:

:1: error: illegal start of simple expression
val orderItemsReduce = orderItemsMap.reduce((acc, val) => acc + val)
^

Regards,
Swetha.

Issue got rectified after using space before and after ‘+’ symbol in the expression.

Thanks

are you using reduce instead of reduceByKey? is it a typo? or am i missing something?

@saranvisa - i am using reduce() function in order to perform aggregation (sum). It is generally used to get the sum, min, max values in any table.

Thanks

1 Like