admin管理员组文章数量:1384197
I need to de-dupe the data, the data fields are as follows
id, name,interestedProduct, _timeStamp
.
The data is stored in a delta lake.
I have learned that there is a way to increase the efficiency of de-duplication.
Here is my code:
df = spark.sql('select * from dwd.tb_customer')
cols = ['id','name','interestedProduct','_timeStamp']
df = df.sortWithinParition(“id”).dropDuplicates(cols)
After testing, this method does improve the efficiency of de-duplication.
But my question is:
sortWithinParitions
is sorting by partition, while dropDuplicates
is de-duplicating globally.
So why is it more efficient to sort the data and then do the de-duplication?
And I found out that there is an argument that although dropDuplicates
is global de-duplication, sortWithinParition('id').dropDuplicates(cols)
is optimized by the executor to do the de-duplication inside each partition.
If this is correct, then de-duplicating and finally merging is done in the partitions, then if we don't use repartition('id')
in partitioning the data
then the end result may still be duplicate records.
So how exactly does dropDuplicates
work.
Why sortWithinParition + dropDuplicates
can be more efficient?
If sortWithinParition + dropDuplicates
is used for de-duplication, is it true that the executor will optimize dropDuplicates
to de-duplicate within a partition?
本文标签: Efficiency of sortWithinPartitions and dropDuplicates in SparkStack Overflow
版权声明:本文标题:Efficiency of sortWithinPartitions and dropDuplicates in Spark - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744482000a2608225.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论