How to get values of a Spark Dataframe Column having children of its own?

Viewed 93

I have a Dataframe with the following schema -

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)

I want to extract values of just the country into a list, but when I do so, the children come along as well. Is there some way to get only the values of the country and not its children?

EDIT: Added printSchema() output above. If I have country = "USA" with State = "California", "NY"; capital = "Washington DC"; and so on, I want to extract the value "USA", without taking any other values.

0 Answers
Related