EX-15: Attribute Survivorship with max_by()
Track: Entity Resolution & MDM • Difficulty: Advanced • Mastery Points: 200 PTS
Business Problem Scenario
When duplicate customer accounts are resolved into a single golden record, naive approaches that pick an arbitrary whole row corrupt master data. True golden record survivorship must operate attribute by attribute based on domain authority: legal customer name must survive from the Core Mainframe KYC system (source_priority = 2), while email contact information must survive from the retail CRM based on the most recent interaction timestamp (updated_at).
Engineering Objective
Create the golden record view gold.customer_golden aggregating matched customer records. • Expected Columns: entity_id, full_name, email, phone, postcode • Survivorship Rules: - Group by entity_id. - full_name: max_by(full_name, source_priority) (Core Banking system priority 2 > CRM priority 1). - email: max_by(email, updated_at) (latest contact timestamp wins). - phone: max_by(phone, source_priority). - postcode: max_by(postcode, updated_at). • Attribute-Level Rationale: Surviving attributes independently ensures that verified KYC legal names are preserved from the core ledger while fresh contact details are captured from digital channels. Key Concepts: - Attribute Survivorship: Granular business rules determining the winning attribute value for each golden entity field. - max_by(col, order_col): Spark SQL function returning the value of col corresponding to the maximum value of order_col.
Target Table: silver.matched_customers (entity_id STRING, full_name STRING, email STRING, phone STRING, postcode STRING, source_priority INT, updated_at TIMESTAMP)
Verification & Architecture Insights
Per-attribute survivorship ensures that the golden customer entity inherits the authoritative legal identity from KYC onboarding while keeping the freshest digital contact info.