How to convert column of arrays of strings to strings?

后端 未结 4 2054
死守一世寂寞
死守一世寂寞 2020-12-13 16:23

I have a column, which is of type array < string > in spark tables. I am using SQL to query these spark tables. I wanted to convert the array < s

4条回答
  •  情书的邮戳
    2020-12-13 17:10

    You can cast array to string at create this df not at output

    newdf = df.groupBy('aaa')
      .agg(F.collect_list('bbb').("string").alias('ccc'))
    
    outputdf = newdf.select(
      F.concat_ws(', ' , newdf.aaa, F.format_string('xxxxx(%s)', newdf.ccc)))
    

提交回复
热议问题