Spark Dataframe: Generate an Array of Tuple from a Map type

前端 未结 1 1942
粉色の甜心
粉色の甜心 2021-01-24 11:40

My downstream source does not support a Map type and my source does and as such sends this. I need to convert this map into an array of struct (tuple).

Scala support Ma

1条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-24 12:16

    Just use an udf:

    val toArray = udf((vs: Map[String, String]) => vs.toArray)
    

    and adjust input type according to your needs.

    0 讨论(0)
提交回复
热议问题