How do we resolve raw CRM leads against established master accounts and coalesce fallback master IDs?
An entity resolution pipeline performing aliased left joins and coalescing master account keys with lead keys.
Enterprise Master Data Management (MDM), customer identity resolution, and marketing attribution.
from pyspark.sql.functions import col, coalesce
resolved_df = raw_leads.alias("lead").join(
crm_accounts.alias("crm"),
col("lead.email") == col("crm.primary_email"),
"left"
).select(
col("lead.lead_id"),
coalesce(col("crm.account_id"), col("lead.lead_id")).alias("master_id"),
col("lead.email"),
col("crm.company_name")
)Practice typing production-grade PySpark code for Complex Relational Entity Resolution Pipeline.