pyspark udf返回值

pyspark udf返回值,pyspark,user-defined-functions,Pyspark,User Defined Functions,我创建了一个udf,它返回列表列表(内置列表对象)。我将返回的值保存到一个新列,但发现它已转换为字符串。我需要它作为一个列表列表,以便激活posexplode,正确的方法是什么 def conc(hashes, band_width): ... ... return combined_chunks #it's type: list[list[float]] concat = udf(conc) #bands column becomes a string mh2

我创建了一个udf,它返回列表列表(内置列表对象)。我将返回的值保存到一个新列,但发现它已转换为字符串。我需要它作为一个列表列表,以便激活posexplode,正确的方法是什么

def conc(hashes, band_width):   
    ...
    ...
    return combined_chunks #it's type: list[list[float]]

concat = udf(conc)

#bands column becomes a string
mh2 = mh1.withColumn("bands", concat(col('hash'),lit(bandwidth)))
我解决了它:

concat = udf(conc,ArrayType(VectorUDT()))
在conc中:使用vectors.dense返回密集向量列表。

使用
concat=udf(conc,'array')