简体   繁体   English

SPARK:仅在每个分区中删除重复项

[英]SPARK: dropDuplicates in every partitions only

I want to dropDuplicates in every partitions, not the full DataFrame.我想在每个分区中dropDuplicates ,而不是完整的DataFrame。

Is that possible with PySpark? PySpark 有可能吗? Thanks.谢谢。

import pyspark.sql.functions as f
withNoDuplicates = df.withColumn("partitionID", f.spark_partition_id()).dropDuplicates()

Basically you add a column of the partition id using spark_partition_id and then do the distinct, it will consider different partitions separately基本上你使用 spark_partition_id 添加一列分区 id 然后做不同的,它会分别考虑不同的分区

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM