【发布时间】:2018-05-13 04:54:18
【问题描述】:
我想将结构数组分解为列(由结构字段定义)。例如
root
|-- arr: array (nullable = true)
| |-- element: struct (containsNull = true)
| | |-- id: long (nullable = false)
| | |-- name: string (nullable = true)
应该转化为
root
|-- id: long (nullable = true)
|-- name: string (nullable = true)
我可以做到这一点
df
.select(explode($"arr").as("tmp"))
.select($"tmp.*")
如何在单个 select 语句中做到这一点?
我认为这可以工作,不幸的是它没有:
df.select(explode($"arr")(".*"))
线程“主”org.apache.spark.sql.AnalysisException 中的异常:否 这样的结构字段 .* in col;
【问题讨论】:
标签: scala apache-spark dataframe