I don't have any ideas to get column names when it has null value
For example,
case class A(name: String, id: String, email: String, company: String)
val e1 = A("n1", null, "n1@c1.com", null)
val e2 = A("n2", null, "n2@c1.com", null)
val e3 = A("n3", null, "n3@c1.com", null)
val e4 = A("n4", null, "n4@c2.com", null)
val e5 = A("n5", null, "n5@c2.com", null)
val e6 = A("n6", null, "n6@c2.com", null)
val e7 = A("n7", null, "n7@c3.com", null)
val e8 = A("n8", null, "n8@c3.com", null)
val As = Seq(e1, e2, e3, e4, e5, e6, e7, e8)
val df = sc.parallelize(As).toDF
This code makes dataframe like this :
+----+----+---------+-------+
|name| id| email|company|
+----+----+---------+-------+
| n1|null|n1@c1.com| null|
| n2|null|n2@c1.com| null|
| n3|null|n3@c1.com| null|
| n4|null|n4@c2.com| null|
| n5|null|n5@c2.com| null|
| n6|null|n6@c2.com| null|
| n7|null|n7@c3.com| null|
| n8|null|n8@c3.com| null|
+----+----+---------+-------+
and I want to get column names all of their rows are null : id, company
I don't care the type of output. Array, String, RDD whatever
See Question&Answers more detail:
os