Scala Sparks contains vs. does not contain

I can filter - as shown below - tuples in RDD using "contains". But what about filtering RDD using no?

val rdd2 = rdd1.filter(x => x._1 contains ".") 

I can not find the syntax for this. Assuming this is possible and that I am not using DataFrame s. I cannot figure out how to do this with examples of regular expressions and / or filters.

+5
source share
1 answer

This is simply negating the filter predicate contains :

 val rdd2 = rdd1.filter(x => !(x._1 contains ".")) 
+11
source

Source: https://habr.com/ru/post/1259326/


All Articles