-1

When I've implemented the function I wanted it to return an RDD. And probably collect it to List later. But why does it return Unit instead? What should I change in the implementation to make it return an RDD?

Sales is a map (saleId, Saletype) - val sales: Map[Int, String]

val processSales: Unit = sales.foreach(sale => sc.makeRDD(salesService.getData(sale._1)))
samba
  • 2,821
  • 6
  • 30
  • 85

1 Answers1

3

foreach returns Unit, You can see the return type as below

def foreach(f: T => Unit): Unit =

Use map instead to return an RDD

def map[U: ClassTag](f: T => U): RDD[U] =

koiralo
  • 22,594
  • 6
  • 51
  • 72