【发布时间】:2019-07-31 05:27:38
【问题描述】:
如何将数据类型为 struct 的列转换为 Map 或 String。这是架构:
root
|-- Col1: string (nullable = true)
|-- Col2: struct (nullable = true)
| |-- _1: string (nullable = true)
| |-- _2: integer (nullable = false)
当我想将数据框转储到文件中时,第二列会出现问题。我尝试了许多不同的方法,例如转换为字符串,但它改变了第二列中的值。我也尝试将 Col2 转换为地图,但没有成功。
我试图通过 udf 获取 struct(_1) 中的第一个值,但它有错误:
执行用户定义函数失败($anonfun$1: (struct
【问题讨论】:
标签: scala dataframe struct type-conversion user-defined-functions