Given a DataFrame with the following rows:
rows = [
Row(col1='abc', col2=[8], col3=[18], col4=[16]),
Row(col2='def', col2=[18], col3=[18], col4=[]),
Row(col3='ghi', col2=[], col3=[], col4=[])]
I'd like to remove rows with an empty array for each of col2, col3 and col4 (i.e. the 3rd row).
For example I might expect this code to work:
df.where(~df.col2.isEmpty(), ~df.col3.isEmpty(), ~df.col4.isEmpty()).collect()
I have two problems
- how to combine where clauses with
andbut more importantly... - how to determine if the array is empty.
So, is there a builtin function to query for empty arrays? Is there an elegant way to coerce an empty array to an na or null value?
I'm trying to avoid using python to solve it, either with a UDF or .map().