I have a dataframe with the following schema:
|-- A: map (nullable = true)
| |-- key: string
| |-- value: array (valueContainsNull = true)
| | |-- element: struct (containsNull = true)
| | | |-- id: string (nullable = true)
| | | |-- type: string (nullable = true)
| | | |-- index: boolean (nullable = false)
|-- idkey: string (nullable = true)
Since the value in the map is of type array, I need to extract the field index corresponding to the id in the "foreign" key field idkey.
For example, I have the following data:
{"A":{
"innerkey_1":[{"id":"1","type":"0.01","index":true},
{"id":"6","type":"4.3","index":false}]},
"1"}
Since the idkey is 1, we need to to output the value of index corresponding to the element where "id":1, i.e. the index should be equal to true. I am really not sure how I can accomplish this, with UDFs or otherwise.
Expected output is:
+---------+
| indexout|
+---------+
| true |
+---------+
i.e. the index should be equal to 0?? and can you share your expected output tooSince the idkey is 1, we need to to output the value of index corresponding to the element where "id":1, i.e. the index should be equal to falsecontradicting with each other?