【发布时间】:2020-12-08 00:59:56
【问题描述】:
我有一个 Spark 数据框,其中一列(称为 features)是结构类型,具体来说:
struct<type:tinyint,size:int,indices:array<int>,values:array<double>>
当我执行df.printSchema() 时,我得到的是:
root
|-- features: vector (nullable = true)
我想做的是将上述结构的values 放在单独的列中。
我试过了:
df.select("features.values").show()
然后我得到错误:
AnalysisException: Can't extract value from features#125369: need struct type but got struct<type:tinyint,size:int,indices:array<int>,values:array<double>>;
我不明白,尤其是上面写着need struct type but got struct (??) 的部分。有人可以帮我解决这个问题吗?
【问题讨论】:
标签: apache-spark pyspark apache-spark-sql