如何获得sparkDataframe列的值,该列有自己的子列?

c2e8gylq  于 2021-05-29  发布在  Spark
关注(0)|答案(0)|浏览(204)

我有一个具有以下模式的Dataframe-

root
|--country: struct (nullable = true)
|  |--state: struct (nullable = true)
|  |  |--city: string (nullable = true)
|  |--capital: string (nullable = true)
|  |--language: string (nullable = true)
|  |  |--script: string (nullable = true)

我只想提取 country 但当我这么做的时候,孩子们也会跟着来。有没有办法只得到 country 而不是它的孩子?
编辑:在上面添加了printschema()输出。如果我有country=“usa”和state=“california”、“ny”;capital=“华盛顿特区”;以此类推,我想提取值“usa”,而不取任何其他值。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题