【发布时间】:2018-12-05 20:31:41
【问题描述】:
我的数据集ds 具有以下架构:
root
|-- id: string (nullable = true)
|-- type: string (nullable = true)
|-- item: struct (nullable = true)
| |-- item: string (nullable = true)
示例:
{"id":"1","type": "aaa", "item": {"item":"11"}}
{"id":"2","type": "bbb", "item" : {"item":"12"}}
如何从结构中检索item 以获得此结果?
id type item
1 aaa 11
2 bbb 12
这是我尝试但没有成功的方法:
ds.select("id", "type", "item.0");
请注意我使用的是 Java。不要在 Scala 或 Python 中发布答案,除非它们与 Java 相同。
【问题讨论】:
-
题主有什么问题?
-
ds.select("id", "type", "item.item")
标签: java apache-spark apache-spark-sql