thebluephantom thebluephantom - 1 month ago 26
Scala Question

SPARK SCALA contain vs. not contain

I can filter - as per below - tuples in RDD. But what about the "not contains"? Cannot find the syntax for this. Assuming it is possible and am not using a data frame. Cannot see from regex and filter examples. Thanks in advance.

val z = y.filter(x => x._1 contains ".")

Answer

It's just the negation of the contains filter :

val z = y.filter(x => !(x._1 contains "."))
Comments