pyspark dataframe 多列數據當咱們想存儲爲text格式的時候:sql
df.coalesce(1).write.format("text").option("header", "false").mode("append").save("<path>")
咱們發現報錯:app
pyspark.sql.utils.AnalysisException: 'Text data source supports only a single column,
解決辦法就是將多列拼接爲一列string字符串spa
dataFrameWithOnlyOneColumn = dataFrame.select(concat(*dataFrame.columns).alias('data')) dataFrameWithOnlyOneColumn.coalesce(1).write.format("text").option("header", "false").mode("append").save("<path>")