: error: type mismatch; found : Unit

apache-spark

#1

Dear All , I am trying this below code snipet…

val orders = sc.textFile("/public/retail_db/orders")
val ordersCompletedCount = sc.accumulator(0, “orders completed count”);
val ordersNonCompletedCount = sc.accumulator(0, “orders Non completed count”);
val ordersFilterd = orders.
filter(order => {
val isCompletedOrder = order.split(",")(3) == “COMPLETE” || order.split(",")(3) == "CLOSED"
if(isCompletedOrder) ordersCompletedCount += 1
else ordersNonCompletedCount += 1
})

Getting Below Erro:
:36: error: type mismatch;
found : Unit
required: Boolean
if(isCompletedOrder) ordersCompletedCount += 1
^
I am not sure what i am missing


#2

I got the answer …Filter always need to return type so need to return either ordersCompletedCount or ordersNonCompletedCount…Thanks