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

前端 未结 1 1941
粉色の甜心
粉色の甜心 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)
提交回复
热议问题