Monitor Friend-Request System for Quality and Abuse
Company: Snapchat
Role: Data Scientist
Category: Data Manipulation (SQL/Python)
Difficulty: Medium
Interview Round: Technical Screen
Friendship
+--------------+-------------+---------------------+---------------------+
| requester_id | approver_id | request_ts | approval_ts |
+--------------+-------------+---------------------+---------------------+
| 1 | 2 | 2023-10-01 10:00:00 | 2023-10-01 12:00:00 |
| 3 | 4 | 2023-10-01 11:00:00 | NULL |
| 5 | 6 | 2023-10-02 09:00:00 | 2023-10-02 09:05:00 |
| 7 | 8 | 2023-10-02 14:00:00 | 2023-10-05 10:00:00 |
+--------------+-------------+---------------------+---------------------+
Users
+---------+---------+
| user_id | is_spam |
+---------+---------+
| 1 | F |
| 2 | F |
| 3 | T |
| 4 | F |
| 5 | F |
+---------+---------+
##### Scenario
Friend-request system wants to monitor quality and abuse for the past week using Friendship and Users tables.
##### Question
Q1. Write an SQL query that returns each of the last 7 calendar days together with the same-day acceptance rate (approvals that occurred on the same date as the request divided by total requests that day). Q2. Write an SQL query that yields the percentage of friendship requests last week that did NOT originate from accounts marked spam = 'T'. Q3. The Users table may be incomplete (new users not yet present). Propose at least one data or query change to make Q1-Q2 robust, and list the key hypotheses and edge cases you would validate when interpreting the results.
##### Hints
Think DATE(request_ts)=DATE(approval_ts); left joins to Users; NULL handling, late approvals, missing rows, timezone cut-offs.
Quick Answer: This question evaluates a candidate's ability to compute time-based acceptance metrics, reason about data quality and abuse signals, and apply joins and filters in SQL/Python while accounting for nulls and incomplete user records.