I am trying to find a particular array (of type Double) based on another column with minimum value. The following code works to extract the array but I am unable to receive it as Array[Double]. Tried mapping and casting from as found from other threads but could not solve the problem. I would be grateful for any hints. The following is the illustration:
scala> df.show
+----+---------------+
|time| crds|
+----+---------------+
|12.0|[0.1, 2.1, 1.2]|
| 8.0|[1.1, 2.1, 3.2]|
| 9.0|[1.1, 1.1, 2.2]|
+----+---------------+
scala> val minTime = df.select(min(col("time"))).collect()(0)(0).toString.toDouble
minTime: Double = 8.0
scala> val crd = df.filter($"time" === minTime).select($"crds").take(1)
crd: Array[org.apache.spark.sql.Row] = Array([WrappedArray(1.1, 2.1, 3.2)])
scala> val res: Array[Double] = crd.array
<console>:29: error: type mismatch;
found : Array[org.apache.spark.sql.Row]
required: Array[Double]
val res: Array[Double] = crd.array
^
scala>