apache spark中的以下scala代码行将在8个分区中随机分割数据:
import org.apache.spark.sql.functions.rand
df
.repartition(8, col("person_country"), rand)
.write
.partitionBy("person_country")
.csv(outputPath)
有人能教我怎么用Pypark做同样的事情吗?我自己用下面的代码尝试过,但是失败了
from pyspark.sql.functions import rand
df\
.repartition(8, col("person_country"), rand)\
.write.partitionBy("person_country")\
.format('csv').mode('Overwrite')\
.save("outputPath")
有什么想法吗?
1条答案
按热度按时间wz8daaqr1#
repartition(8, col("person_country"), rand())
在rand后面加括号