【发布时间】:2018-11-06 13:20:35
【问题描述】:
我需要将一个空的 StructType 列添加到现有的 DataFrame 中。
尝试以下:
df = df.withColumn("features", typedLit(StructType(Nil)))
还有:
df = df.withColumn("features", lit(new GenericRowWithSchema(Array(), StructType(Nil))))
但是,在上述两种情况下,都会因不支持的文字类型而出现错误。
【问题讨论】:
标签: scala apache-spark