← Meta Interview Insights

Meta·Data Scientist·Technical Phone Screen·Senior

Senior
Sep 2025Remote

Summary

SQL-heavy technical screen for a DS role at Meta. Three questions, all centered on the same schema, escalating from basic aggregation to rolling windows to defining your own metric from scratch. The last one was the hardest by far.

Questions Asked (3)

Q1

Given tables for users, shops, posts, impressions, and clicks, compute a ShopVisibilityScore per shop per calendar date as the share of daily unique viewers who saw at least one shoppable post from that shop. Also report merchant-click CTR, total impressions, and unique viewers for those shoppable posts. Handle duplicate impressions correctly.

Product Analytics & MetricsData Modeling
Author's notes

The dedup part is where I tripped up first.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the definitions of 'shoppable post', 'unique viewer', and 'merchant-click', then outline a SQL pipeline that joins impressions to posts and shops, deduplicates impressions per user-post-day, and aggregates daily metrics. Compute the visibility score as the ratio of unique viewers who saw at least one shoppable post from the shop to the total unique viewers that day, and separately calculate CTR, total impressions, and unique viewers for those posts.

Pro tip: Explicitly state your deduplication strategy (e.g., using DISTINCT or ROW_NUMBER) and how you handle edge cases like users with multiple impressions or missing click data, as this demonstrates attention to data quality and metric reliability.

1. Clarify definitions and assumptions

Confirm what constitutes a 'shoppable post', 'unique viewer', and 'merchant-click', and whether the visibility score is per shop per day across all users or only among users who saw any shoppable post.

2. Deduplicate impressions

Deduplicate impressions at the user-post-day level to ensure each user is counted once per post per day, using DISTINCT or ROW_NUMBER to handle duplicate impression records.

3. Compute daily unique viewers per shop

For each shop and calendar date, count distinct users who saw at least one shoppable post from that shop, and also compute the total distinct users active that day (or the relevant denominator).

4. Calculate visibility score and other metrics

Compute ShopVisibilityScore as the ratio of unique viewers of the shop's shoppable posts to total unique viewers that day; separately calculate merchant-click CTR (clicks/impressions), total impressions, and unique viewers for those posts.

5. Validate and present results

Check for anomalies (e.g., CTR > 100%), ensure date ranges are complete, and present the final table with shop_id, date, visibility_score, ctr, total_impressions, and unique_viewers.

Key Points to Mention

  • Deduplication of impressions at the user-post-day level to avoid overcounting unique viewers.
  • Definition of 'unique viewer' as a distinct user who saw at least one shoppable post from the shop on that date.
  • Handling of missing or null click data and ensuring clicks are attributed only to shoppable posts.
  • Choice of denominator for ShopVisibilityScore: total daily unique viewers across all shops vs. only those exposed to any shoppable post.
  • Use of window functions or subqueries to efficiently compute distinct counts and ratios in SQL.
  • Consideration of time zones and date boundaries when aggregating by calendar date.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

Extend the daily metrics to a 7-day rolling window ending on 2025-09-01 per shop, making sure the window logic doesn't bleed across shops. Then show the absolute and percentage change compared to the prior 7-day window.

Product Analytics & MetricsA/B Testing & Experimentation
Author's notes

Window functions across shops tripped me up for a second because I initially wrote PARTITION BY shop_id but forgot the date ordering.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the data model and confirm the grain (daily per shop). Then, use a window function partitioned by shop and ordered by date to compute the 7-day rolling sum for the current and prior windows, ensuring the window frame is correctly defined. Finally, calculate absolute and percentage changes, handling edge cases like missing days or zero denominators.

Pro tip: Always explicitly define the window frame (e.g., ROWS BETWEEN 6 PRECEDING AND CURRENT ROW) and use a date spine to fill gaps, as missing dates can silently break rolling calculations. Also, mention that percentage change should be computed as (current - prior) / NULLIF(prior, 0) to avoid division by zero.

1. Clarify requirements and data

Confirm the metric definition, date range, and that data is daily per shop. Check for missing dates or duplicate entries.

2. Create a complete date-shop spine

Generate a cross join of all shops and all dates in the range to ensure every shop has a row for each day, filling missing metrics with 0 or NULL as appropriate.

3. Compute rolling windows with partitioning

Use a window function partitioned by shop and ordered by date to calculate the 7-day rolling sum for the current window (ending 2025-09-01) and the prior 7-day window (ending 2025-08-25).

4. Calculate absolute and percentage change

Compute the difference and percentage change between the two windows, using NULLIF to handle zero denominators.

5. Validate and present results

Check for anomalies, ensure no cross-shop contamination, and present the final table with shop, current window sum, prior window sum, absolute change, and percentage change.

Key Points to Mention

  • Partitioning by shop to prevent window bleeding across shops
  • Defining the window frame explicitly (e.g., ROWS BETWEEN 6 PRECEDING AND CURRENT ROW)
  • Handling missing dates with a date spine to avoid incorrect rolling sums
  • Using NULLIF or CASE to avoid division by zero in percentage change
  • Ensuring the window ends exactly on 2025-09-01 and prior window ends on 2025-08-25
  • Validating results by checking a few shops manually or with summary statistics

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q3

Define a PurchaseIntentRate metric using only the provided tables, then implement it in SQL per shop per date. The suggested definition is: among users who had a first shoppable impression for a shop on a given date, what fraction clicked a merchant link within 60 minutes of that first impression? Justify whether users who clicked on non-shoppable posts should be included or excluded.

Product Analytics & MetricsData ModelingProduct Sense & Ideation
Author's notes

This one took the most time.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the metric definition and edge cases, such as the 60-minute window and handling of multiple impressions. Then, write SQL that identifies each user's first shoppable impression per shop per date, joins to click events within 60 minutes, and computes the fraction. Finally, justify the inclusion/exclusion of non-shoppable clicks based on the metric's intent to measure purchase intent from shoppable content.

Pro tip: Explicitly state your assumptions about the data model (e.g., event timestamps, user IDs) and consider using window functions like ROW_NUMBER() to efficiently get the first impression per user per shop per date.

1. Clarify the metric and assumptions

Restate the metric definition and confirm details like time window, user identification, and what constitutes a 'shoppable impression' and 'merchant link click'. State any assumptions about the tables.

2. Identify first shoppable impressions

Use a subquery with ROW_NUMBER() partitioned by user, shop, and date, ordered by impression timestamp, to select the first shoppable impression for each user-shop-date.

3. Join with click events

Left join the first impressions to click events on user_id and shop_id, where click timestamp is between impression timestamp and impression timestamp + 60 minutes.

4. Compute the rate

For each shop and date, calculate the fraction of users with at least one qualifying click divided by the total number of users with a first shoppable impression.

5. Justify inclusion/exclusion of non-shoppable clicks

Argue that non-shoppable clicks should be excluded because the metric aims to measure intent from shoppable content; including them would conflate different user behaviors and dilute the metric's meaning.

Key Points to Mention

  • Use of window functions (e.g., ROW_NUMBER) to identify first impressions per user per shop per date.
  • Handling of time zones and timestamp precision in the 60-minute window.
  • Definition of 'shoppable impression' and 'merchant link click' based on available tables.
  • Treatment of users with multiple impressions or clicks (e.g., only first impression counts, any click within window counts).
  • Justification for excluding non-shoppable clicks: metric focuses on purchase intent from shoppable content, and including them would introduce noise.
  • Potential edge cases: users who click before impression (should be excluded), or clicks exactly at 60 minutes (inclusive or exclusive).

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.