Normalize Uploaded WhatsApp Contact Phone Numbers to E.164

Last updated: November 29, 2026

Quick Overview

A contact upload table has (uploader_id, uploader_country, raw_phone) with numbers in mixed formats like '(415) 555-0100', '+44 20 7946 0958' and '0044...'. Normalize each to E.164 using the uploader's country calling code when no international prefix is present, drop invalid lengths, and dedupe contacts per uploader.

Meta
Data Manipulation (SQL/Python)
Software Engineer
Meta
November 29, 2026
Software Engineer
Phone Screen
Data Manipulation (SQL/Python)
Easy

0

0

0 solved


A contact upload table has (uploader_id, uploader_country, raw_phone) with numbers in mixed formats like '(415) 555-0100', '+44 20 7946 0958' and '0044...'. Normalize each to E.164 using the uploader's country calling code when no international prefix is present, drop invalid lengths, and dedupe contacts per uploader.

WhatsApp and Messenger contact sync must match uploaded address books to accounts, and normalization quality directly affects friend and contact discovery. This phone screen question checks vectorized string cleaning in pandas, applying per-row country context, and sensible validation.

What the Interviewer Expects
  • Strip formatting characters with a vectorized regex
  • Handle '+' and '00' international prefixes
  • Apply the uploader's country code and drop a national trunk '0' where relevant
  • Validate digit length against E.164 limits
  • Dedupe per uploader after normalization, not before
Key Topics to Cover
str.replace regex
string normalization
E.164
validation
deduplication
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
  • Why would you use a library like libphonenumber in production instead of rules?
  • How would you handle numbers whose country is ambiguous because the uploader traveled?
  • How would you hash numbers before matching for privacy?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice SQL Problems
Sample Answer
Clarify the Data

A small mapping gives calling codes: US 1, GB 44, IN 91, BR 55. E.164 allows at most 15 digits after the '+'. For a national-format number, I strip one leading '0' (the trunk prefix used in GB, IN, BR...

Approach

Record whether the raw string starts with '+' or '00', then remove every non-digit with str.replace(r'\D', '', regex=True). International numbers keep their digits (minus a leading '00'). National n...


Submit Your Answer
Markdown supported