I guess the answer to this question might be too obvious.
Yet I would like to know how to get a list of values that are not present as key for any pair in my RDD e.g.
pairs = [(3,2),(1,3),(1,4)] to [2,4]
keys = pairs.keys().distinct()
Now i want to filter the values of pairs and give back only those that are not in keys, something like:
filteredValues = pairs.values().filter(lambda x: x not in keys)
Error I get:
Exception: It appears that you are attempting to broadcast an RDD or reference an RDD from an action or transformation. RDD transformations and actions can only be invoked by the driver, not inside of other transformations; for example, rdd1.map(lambda x: rdd2.values.count() * x) is invalid because the values transformation and count action cannot be performed inside of the rdd1.map transformation. For more information, see SPARK-5063.
So I see obviously that the problem is that I use keys (RDD2) inside of pairs' (RDD1) filtering function. The question is, how can I overcome that in still get my filtering right?
Constructive help appreciated. Thanks.