← Meta Interview Insights

Meta·Data Scientist·Technical Phone Screen·Senior

SeniorPrefer not to say
Sep 2025Remote

Summary

Meta DS interview with some seriously involved SQL. Three questions, all feed-related, and the last one on retention cohorts had me second-guessing my window function logic the whole time. Solid technical round, no behavioral stuff at all.

Questions Asked (3)

Q1

For each session, compute ad frequency as ads divided by total impressions (ads plus organic) considering only feed positions 2 and above, then flag sessions where that frequency exceeds 30%.

Product Analytics & MetricsData Modeling
Author's notes

Straightforward filter-then-aggregate setup but I initially forgot to restrict to position >= 2 and computed it over all rows.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the data schema and definitions (e.g., what constitutes an ad vs. organic impression, how feed positions are indexed). Then outline a step-by-step SQL or pandas approach: filter to positions >= 2, aggregate per session, compute frequency, and flag sessions exceeding 30%. Finally, discuss edge cases and validation.

Pro tip: Mention that you would validate the 30% threshold by checking the distribution of ad frequency across sessions to ensure it's not an arbitrary cutoff, and consider whether the threshold should be dynamic based on user engagement metrics.

1. Clarify definitions and data schema

Confirm what counts as an ad impression vs. organic impression, and how feed positions are represented (e.g., 1-indexed). Ensure you understand session identification and any time constraints.

2. Filter and aggregate data

Filter the events table to include only feed positions >= 2. Then group by session_id and count ad impressions and organic impressions separately.

3. Compute ad frequency

For each session, calculate ad frequency as (ad impressions) / (ad impressions + organic impressions). Handle potential division by zero if a session has no impressions in positions >= 2.

4. Flag sessions exceeding threshold

Create a binary flag or filter sessions where ad frequency > 0.30. Consider whether to use > or >= based on business rules.

5. Validate and interpret results

Check the distribution of ad frequency, investigate outliers, and ensure the flag aligns with business expectations. Discuss potential next steps like A/B testing or user segmentation.

Key Points to Mention

  • Importance of clarifying ad vs. organic impression definitions and position indexing.
  • Handling sessions with zero impressions in positions >= 2 (avoid division by zero).
  • Using SQL window functions or pandas groupby for efficient computation.
  • Considering the impact of the 30% threshold and whether it's a hard rule or adjustable.
  • Validating results by examining the distribution and potential outliers.
  • Communicating findings to stakeholders with clear visualizations or summary stats.

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

Q2

Compute ad click-through rate by position bin (positions 1-2, 3-5, and 6+), joining impressions to clicks, and then compute a user-fixed-effect adjusted CTR by subtracting each user's mean CTR from the per-bin CTR.

A/B Testing & ExperimentationProduct Analytics & MetricsData Modeling
Author's notes

The binning part was fine, just a case-when on feed_position.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the data schema and definitions (impressions, clicks, user_id, position). Then write a SQL query that joins impressions to clicks, bins positions, and computes CTR per bin. Finally, compute user-level mean CTR and subtract it from each bin's CTR to get user-fixed-effect adjusted CTR, ensuring to handle users with no clicks or impressions appropriately.

Pro tip: When computing user-fixed-effect adjusted CTR, be careful with users who have zero impressions or clicks—decide whether to exclude them or impute their mean CTR, and document your choice. Also, consider using a weighted average for the overall adjusted CTR to avoid Simpson's paradox.

1. Clarify data and definitions

Confirm the table structures, what constitutes an impression and a click, and how position is recorded. Ensure you understand the granularity (e.g., per impression or per user-position).

2. Join impressions to clicks

Use a LEFT JOIN from impressions to clicks on impression_id (or equivalent) to retain all impressions, marking clicks as 1 if a click exists, else 0.

3. Bin positions and compute CTR

Create position bins (1-2, 3-5, 6+) using a CASE statement. Then compute CTR per bin as SUM(clicks)/SUM(impressions).

4. Compute user mean CTR

Calculate each user's overall CTR (total clicks / total impressions) across all positions. Handle users with zero impressions by excluding them or setting mean CTR to 0.

5. Adjust CTR by user fixed effect

For each user and bin, compute the difference between the bin's CTR and the user's mean CTR. Then average these differences across users per bin to get the adjusted CTR.

Key Points to Mention

  • Importance of clarifying data schema and definitions before writing queries.
  • Using LEFT JOIN to ensure all impressions are counted, even those without clicks.
  • Handling edge cases: users with zero impressions or clicks, and positions outside the specified bins.
  • Weighted vs. unweighted averages when aggregating user-level adjusted CTRs.
  • Potential for Simpson's paradox and the need to check for confounding.
  • Efficiency considerations: using window functions or subqueries to compute user means.

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

Q3

For the last 7 days, compute D1 and D7 retention for two cohorts: users who saw at least one ad vs users who saw zero ads. Cohorts are defined by each user's first activity date within that window. Return a single table with cohort date, cohort type, D1 retention, and D7 retention.

A/B Testing & ExperimentationProduct Analytics & MetricsRoot Cause Analysis
Author's notes

This one took me the longest to structure.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the definitions: D1 retention means a user returns exactly 1 day after their first activity date, and D7 means exactly 7 days after. Then, for each user, determine their first activity date within the last 7 days, assign them to a cohort (ad-exposed vs. zero-ad) based on whether they saw at least one ad on that first day, and compute retention by checking if they had any activity on day 1 and day 7 after their first activity date. Finally, aggregate by cohort date and cohort type to produce the required table.

Pro tip: Be explicit about how you handle users who are not yet eligible for D7 (e.g., those whose first activity was less than 7 days ago) — typically they are excluded from D7 calculation or treated as not retained, and state your choice clearly.

1. Clarify definitions and assumptions

Confirm what 'first activity date' means (e.g., first event of any type), how ad exposure is measured (e.g., at least one ad impression on the first day), and whether retention is exact-day or any activity on or after that day. Also define the 7-day window relative to today.

2. Identify first activity and cohort assignment

For each user, find their minimum activity date within the last 7 days. That date is their cohort date. Determine if they saw at least one ad on that date; if yes, they belong to the 'saw ad' cohort, otherwise 'zero ads' cohort.

3. Compute retention flags

For each user, check if they had any activity exactly 1 day after their first activity date (D1) and exactly 7 days after (D7). Create binary flags for D1 and D7 retention.

4. Aggregate and calculate retention rates

Group by cohort date and cohort type. Calculate D1 retention as the average of the D1 flag (or count of retained users divided by cohort size) and similarly for D7. Ensure to handle cases where D7 is not yet observable (e.g., exclude those cohorts from D7 or mark as NULL).

5. Format and validate output

Return a table with columns: cohort_date, cohort_type, d1_retention, d7_retention. Validate that the numbers make sense (e.g., D1 >= D7 typically) and consider edge cases like small cohort sizes.

Key Points to Mention

  • Definition of retention: exact-day vs. any activity on or after that day; clarify which is expected.
  • Cohort definition: first activity date within the last 7 days, and ad exposure measured on that first day.
  • Handling of incomplete data: users whose first activity is too recent to have a D7 observation.
  • Aggregation method: retention rate as percentage of cohort size, ensuring correct denominator.
  • Potential confounders: differences in user quality or intent between ad-exposed and zero-ad users, which may affect retention.
  • SQL implementation considerations: use of window functions (MIN OVER), date arithmetic, and conditional aggregation.

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