Reputation: 21
Say, I have a dataframe. Few of the column values in that dataframe is Array() i.e., Array[Nothing]. How can i filter these? because if i don't it will throw error if someone tries to print the dataframe or so.
Upvotes: 0
Views: 33
Reputation: 13581
Just filter the empty array.
val df1 = df.withColumn("array", array())
df1.show()
+---+-----+
| id|array|
+---+-----+
| 1| []|
+---+-----+
val df2 = df1.filter("array != array()")
df2.show()
+---+-----+
| id|array|
+---+-----+
+---+-----+
Upvotes: 1