pyspark.sql.functions.
array_contains
Collection function: returns null if the array is null, true if the array contains the given value, and false otherwise.
New in version 1.5.0.
Column
name of column containing array
value or column to check for in array
Examples
>>> df = spark.createDataFrame([(["a", "b", "c"],), ([],)], ['data']) >>> df.select(array_contains(df.data, "a")).collect() [Row(array_contains(data, a)=True), Row(array_contains(data, a)=False)] >>> df.select(array_contains(df.data, lit("a"))).collect() [Row(array_contains(data, a)=True), Row(array_contains(data, a)=False)]