I've got a Dataset<Row> with the following structure:
{"name": "Ben",
"lastHolidayDestination": "Florida",
"holidays": [
{"destination": "Florida",
"year": 2020},
{"destination": "Lille",
"year": 2019}
]}
I want to add a new column lastHolidayYear to the root of the Dataset using Spark SQL, populated by finding the holidays element that joins onto lastHolidayDestination (assume there will only ever be one). So the output Dataset would be:
{"name": "Ben",
"lastHolidayDestination": "Florida",
"lastHolidayYear": 2020,
"holidays": [
{"destination": "Florida",
"year": 2020},
{"destination": "Lille",
"year": 2019}
]}
I've been playing around with dataset.withColumn() and when() (using Java, but Scala/Python answers are fine) but I've got nowhere so far. I really don't want to use a UDF unless I have to. Any suggestions?