Reputation: 67
so i have a dataframe that looks like this :
|-- id: string (nullable = true)
and i want to achieve one that looks like :
|-- id: string (nullable = true)
How can i achieve that ? i created the case class for the second structure but i don't know to map the first dataframe.
Thanks!
Upvotes: 1
Views: 7027
Reputation: 41957
Use struct
function.
import org.apache.spark.sql.functions._
val newdf = df.select(
$"id", struct($"os_infos", $"product_infos", $"vendor_infos") as "data")
Upvotes: 10