Babu
Babu

Reputation: 891

How do I negate isin method in spark scala

val data= List("z", "f", "h")

sqlContext.sql("select name from table")
          .when($"name".isin(data:_*),1)
          .otherwise(0)
          .show

How do I do the opposite of isin? Do we have anything like isnotin?

Upvotes: 3

Views: 8585

Answers (1)

user8310459
user8310459

Reputation: 148

What you're looking for is either ! method

!($"name".isin(data:_*))

or not function:

import org.apache.spark.sql.functions._

not($"name".isin(data:_*))

Upvotes: 13

Related Questions