← Pinterest Interview Insights
The filtering logic is where I almost tripped up.
Start by clarifying the schema and definitions: identify the event type for clicks, the format field in pin_classification, and how to determine 'new US users' using signup date and country. Then structure the query with CTEs: one to filter events to clicks and impressions for new US users within 30 days of signup, another to join with pin_classification to get format, and finally aggregate to compute CTR as clicks divided by impressions per format.
Pro tip: Always confirm whether CTR should be computed as total clicks divided by total impressions (weighted) or as an average of per-user CTRs; the former is standard for product analytics and avoids bias from low-activity users.
Ask about table columns, event types (e.g., 'click', 'impression'), how to identify US users, and the exact signup date field. Confirm that 'new' means signup_date >= event_date - 30 days.
Use a CTE to select events where the user is from the US and the event date is within 30 days after the user's signup date. Include only click and impression events.
Join the filtered events with pin_classification on pin_id to get the pin format for each event.
Group by pin format and count clicks and impressions separately, using conditional aggregation (e.g., SUM(CASE WHEN event_type = 'click' THEN 1 ELSE 0 END)).
Calculate CTR as clicks / NULLIF(impressions, 0) to avoid division by zero, and consider filtering out formats with very few impressions.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.