tobby
tobby

Reputation: 127

combining two RDDs by values in scala spark

I have two RDDs.

rdd1 = (string, integer)

(a, 10)
(b, 15)
(c, 20)
(d, 20)
(e, 13)

rdd2 = (string, string)

(1, a)
(2, b)
(3, e)

When some of rdd2's values are the same with rdd1's keys, how can I merge them like below? Is it possible?

(1, 10)
(2, 15)
(3, 13)

Upvotes: 0

Views: 269

Answers (1)

user6022341
user6022341

Reputation:

Try:

rdd1.join(rdd2.map(_.swap)).values

Upvotes: 1

Related Questions