Reputation: 10143
I have a WrappedArray
with the following output that I want to extract values from:
val x = df.select("field1").head().get(0)
println(x)
It produces the following output:
WrappedArray([false,/tmp,2])
How do I extract the values from the Array?
Upvotes: 1
Views: 2674
Reputation: 13927
Depends what you want to do with them. You can extract individual items in the array:
df.select($"field1".getItem(0)).head().get(0)
You can explode
the DF:
case class ArrayValue(value: String)
df.explode($"field1") {
case Row(field: Seq[String]) => field.map(ArrayValue(_))
}.show
Upvotes: 2