user132603
user132603

Reputation: 73

How to flatten a RDD of tuple if it has an Option component

I know if I want to transform xs: RDD[Option[T]] to List[T], I simply write xs.flatten

Now if I have a rs:RDD[(Option[T], S)] How do I transform this to RDD[T, S] if there is any option other than calling filter and map.

Upvotes: 1

Views: 95

Answers (1)

fenixil
fenixil

Reputation: 2124

You can call map and use pattern matching:

rs.map {case (Some(t), s) => t->s}

Upvotes: 1

Related Questions