I have a dataframe like this:
root
|-- runKeyId: string (nullable = true)
|-- entities: string (nullable = true)
+--------+--------------------------------------------------------------------------------------------+
|runKeyId|entities |
+--------+--------------------------------------------------------------------------------------------+
|1 |{"Partition":[{"Name":"ABC"},{"Name":"DBC"}],"id":339},{"Partition":{"Name":"DDD"},"id":339}|
and I would like to explode into this with scala:
+--------+--------------------------------------------------------------------------------------------+
|runKeyId|entities |
+--------+--------------------------------------------------------------------------------------------+
|1 |{"Partition":[{"Name":"ABC"},{"Name":"DBC"}],"id":339}
+--------+--------------------------------------------------------------------------------------------+
|2 |{"Partition":{"Name":"DDD"},"id":339}
+--------+--------------------------------------------------------------------------------------------+
spark.read.json("json_path")automatically separates json to rows.