I can use array_contains to check whether an array contains a value.
test = test.withColumn("my_boolean",
F.when(expr("array_contains('check_variable', 'a')"),
1)
.otherwise(0))
Instead of testing for one value I would like to test for multiple values. I could nest:
test = test.withColumn("my_boolean",
F.when(expr("array_contains('check_variable', 'a')"),
1)
F.when(expr("array_contains('check_variable', 'b')"),
1)
.otherwise(0))
Is there a way to do this in one statement, pseudo code:
test = test.withColumn("my_boolean",
F.when(expr("array_contains('check_variable', ['a','b'])"),
1)
.otherwise(0))