Problems / Fuzzy Near-Duplicate Customers / Editorial
norm_name = lower(trim(regexp_replace(name, '[.,-]', '', 'g')))
norm_email = lower(email)
'g'
'J.R. Ewing'
'jr. ewing'
a.norm_email = b.norm_email AND a.norm_name = b.norm_name AND a.id < b.id
canonical_id
duplicate_id
In PySpark, project the normalized DataFrame twice with renamed columns (a_id/b_id, ...) and join on the three conditions — renaming avoids ambiguous-column errors in the self-join.
a_id
b_id
Fuzzy deduplication is really two separate design decisions: what to normalize and what must agree. Normalization must be aggressive enough to unify 'John Smith' / 'john smith.' / 'John- Smith', but the match condition must stay strict enough not to over-merge: the data plants a shared inbox (info@corp.com used by Alice Wong and Bob Trent) that punishes email-only matching, and a repeated name (David Kim at two different emails) that punishes name-only matching. Requiring both keys — plus the a.id < b.id trick for clean pair output — is the standard shape of a pairwise dedupe query, and a 3-record cluster naturally emits all C(3,2) = 3 pairs.
'John Smith'
'john smith.'
'John- Smith'
info@corp.com
David Kim
a.id < b.id
Solve Fuzzy Near-Duplicate Customers yourself →