Skip to main content
PYSPARK • LESSON 224

Highest Priority Deduplication

How can we resolve duplicate records by selecting the record with the highest priority source system?

Advanced3 Minutes830 XP
🤔 THE QUESTION

How can we resolve duplicate records by selecting the record with the highest priority source system?

💡 WHAT IS IT?

Ordering by a custom priority integer or source confidence score inside a Window function resolves duplicate conflicts deterministically.

🎯 WHAT IS IT USED FOR?

Master Data Management (MDM) merging customer records from multiple enterprise CRM systems.

💻 EXAMPLE
w = Window.partitionBy("account_id").orderBy(col("source_priority").desc(), col("last_modified").desc())
df_master = df.withColumn("rank", row_number().over(w)).filter(col("rank") == 1).drop("rank")

🎯 Mission Objectives

Practice typing production-grade PySpark code for Highest Priority Deduplication.

  • Source system priority ranking
  • Deterministic conflict resolution
  • Master Data Management merging