I am new to Spark programming .I am trying to explode column of DataFrame with empty row . I thought explode function in simple terms , creates additional rows for every element in array .But result is different .
I am not able to understand the logic behind the exploded DataFrame . Could someone please explain following example. I want to understand the underlying principle/cause for this result . Why is empty array considered as null in a dataframe ?
//inputDataFrame
+---+------+----------+
|age| name|occupation|
+---+------+----------+
| []|Harish| developer|
+---+------+----------+
df.withColumn("age",explode(col("age")))
//DataFrame with age column exploded
+---+----+----------+
|age|name|occupation|
+---+----+----------+
+---+----+----------+
// expected DataFrame
+---+------+----------+ +----+------+----------+
|age| name|occupation| |age | name|occupation|
+---+------+----------+ (or)+----+------+----------+
| |Harish| developer| |null|Harish| developer|
+---+------+----------+ +----+------+----------+
EDIT1 : As per Chandan , I found this stack question Spark sql how to explode without losing null values and could understand the explode api available for spark2 . But I could not find proper explanation as for why the row was deleted .