I have a spark dataframe in JAVA with nested column
below is the .prinschema()
result
root
|-- BeginDateTime: struct (nullable = true)
| |-- _XmlNodeValue: string (nullable = true)
|-- BusinessDayDate: string (nullable = true)
|-- BusinessUnit: struct (nullable = true)
| |-- UnitID: struct (nullable = true)
I can use dataframe.drop("BeginDateTime")
to drop the BeginDateTime column (as well as all other column right under the root node).
But if I do dataframe.drop("BusinessUnit.UnitID")
, it will not drop it.
I tried this with other columns and they all behave the same: can't drop a nested column.
There are lots of answer for this question but they are all in scala/python. I have to work in a Java environment.
There is one thread (Dropping a nested column from Spark DataFrame), the last answer is in Java. But I can't use his code since line 8 and line 27 error out,
The errors are no method col, no method struct.
Can someone provide me with a working solution in JAVA?
Thanks