随着时间的推移 window 在 pyspark 中删除重复项
Drop duplicates over time window in pyspark
我在从 kafka 主题读取的 spark 中有一个流式数据帧,我想在每次解析新记录时删除过去 5 分钟的重复项。
我知道 dropDuplicates(["uid"])
函数,我只是不确定如何检查特定历史时间间隔内的重复项。
我的理解是:
df = df.dropDuplicates(["uid"])
要么处理当前(微)批次读取的数据,要么处理现在内存中的 "anything" 数据。
有没有办法使用数据中的 "timestamp"
列来设置此重复数据删除的时间?
提前致谢。
df\
.withWatermark("event_time", "5 seconds")\
.dropDuplicates(["User", "uid"])\
.groupBy("User")\
.count()\
.writeStream\
.queryName("pydeduplicated")\
.format("memory")\
.outputMode("complete")\
.start()
我在从 kafka 主题读取的 spark 中有一个流式数据帧,我想在每次解析新记录时删除过去 5 分钟的重复项。
我知道 dropDuplicates(["uid"])
函数,我只是不确定如何检查特定历史时间间隔内的重复项。
我的理解是:
df = df.dropDuplicates(["uid"])
要么处理当前(微)批次读取的数据,要么处理现在内存中的 "anything" 数据。
有没有办法使用数据中的 "timestamp"
列来设置此重复数据删除的时间?
提前致谢。
df\
.withWatermark("event_time", "5 seconds")\
.dropDuplicates(["User", "uid"])\
.groupBy("User")\
.count()\
.writeStream\
.queryName("pydeduplicated")\
.format("memory")\
.outputMode("complete")\
.start()