I have a Spark dataframe where one of the columns (called features
) is a struct type, specifically:
struct<type:tinyint,size:int,indices:array<int>,values:array<double>>
When I do df.printSchema()
, this is what I get:
root
|-- features: vector (nullable = true)
What I would like to do, is to have the values
of the above struct in a separate column.
I have tried:
df.select("features.values").show()
But then I get the error:
AnalysisException: Can't extract value from features#125369: need struct type but got struct<type:tinyint,size:int,indices:array<int>,values:array<double>>;
Which I don't understand, especially the part where it says need struct type but got struct
(??). Can someone help me with this?