I have the following DataFrame
----------
|"ARR" |
----------
|[ |
| "A", |
| "B", |
| "C" |
|] |
----------
Not I want to check whether a specific element is in ARR:
This gives a Error (failed to execute query...):
df\
.withColumn("contains_A",array_contains("A",col("ARR")))\
.show()
same here
df\
.withColumn("contains_A",array_contains(lit("A"),col("ARR")))\
.show()
and this gives FALSE
df\
.withColumn("contains_A",array_contains(array_construct(lit("A")),col("ARR")))\
.show()
How to do it?