I have a DataFrame myDf which contains an array of pairs of points (i.e. x and y coordinates), it has the following schema:
myDf.printSchema
root
|-- pts: array (nullable = true)
| |-- element: struct (containsNull = true)
| | |-- x: float (nullable = true)
| | |-- y: float (nullable = true)
I want to get x and y as individual plain Scala Array's. I think I need to apply the explode-function, but I cannot figure out how. I tried to apply this solution but I cant get it to work.
I'm using Spark 1.6.1 with Scala 2.10
EDIT: I realize that I had a misunderstanding how Spark works, getting the actual arrays is only possible if the data is collected (or using UDFs)