It might be an array containing an empty string:
is_empty = F.udf(lambda arr: arr == [''], T.BooleanType())
Or it might be an array of null:
is_empty = F.udf(lambda arr: arr == [None], T.BooleanType())
To check them all at once you can use:
is_empty = F.udf(lambda arr: arr in [[], [''], [None]], T.BooleanType())
But actually you don't need a UDF for this, e.g. you can do:
df.filter("fruits = array() or fruits = array('') or fruits = array(null)")
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…