I am trying to explode or flatten a column "Body" which is of binary data type. After converting Column Body into string, data is viewed in the below format
{
"header" :
{
"name" : "XYZ",
"company" : "ABC"
}
"payload" :
{
"salary": '"1234"
}
}
I am looking in the below tabular format
name,company,salary
I have tried to explode but it threw an error as it is a binary but when I tried to convert to string, it again threw an error like string data type cannot be exploded
val sample = udf((Body: Array[Byte]) => new String(Body))
val df2 = myDF.withColumn("TMP1", sample(myDF("Body"))).drop("Body")
Could you please suggest a possible solution for the above issue?