spark sql dataframe 写 hdfs 文本 报错:text datasource support only a single colum, and you have 2 columns

    技术2022-07-12  78

    现象:

    spark sql  程序中

    resultFrame.coalesce(1).write.text(outputPath)

    报错 text datasource support only a single colum, and you have 2 columns

    解决:

    将结果连接为一列,使用 

    concat_ws

    如 

    select concat_ws('_', name, age) from students;

     

    Processed: 0.014, SQL: 9