Converting structType to MapType in Spark.
Schema:
event: struct (nullable = true)
| | event_category: string (nullable = true)
| | event_name: string (nullable = true)
| | properties: struct (nullable = true)
| | | prop1: string (nullable = true)
| | | prop2: string (nullable = true)
Sample data:
{ "event": {
"event_category: "abc",
"event_name": "click",
"properties" : {
"prop1": "prop1Value",
"prop2": "prop2Value",
....
}
}
}
Need values as:
event_category | event_name | properties_key | properties_value |
abc | click | prop1 | prop1Value
abc | click | prop2 | prop2Value