← Meta Interview Insights

Meta·Data Scientist·Technical Phone Screen·Senior

Senior
Apr 2026

Summary

Meta DS interview with a meaty SQL problem built around a custom visibility metric. The whole thing was one long multi-part question so there was no real break to collect your thoughts, you just had to keep going.

Questions Asked (4)

Q1

Write a SQL query using CTEs that computes a daily Shop Visibility Score for each shop over a 7-day window. The score is defined as: among sessions with at least one home_feed impression on a given date, what fraction of distinct sessions saw at least one impression from that shop ranked 5 or below on home_feed that same date. Return one row per date and shop with the score, numerator, and denominator.

Product Analytics & MetricsData Modeling
Author's notes

This took me longer than I wanted to admit.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the metric definition and edge cases, then outline the SQL logic using CTEs to compute the numerator and denominator separately before joining. Use a 7-day window to smooth daily fluctuations, ensuring the denominator includes all sessions with at least one home_feed impression on each date.

Pro tip: Mention that you would validate the query by checking for sessions that appear in the numerator but not the denominator, and consider using a window function to compute rolling averages for trend analysis.

1. Clarify requirements and edge cases

Confirm definitions: what constitutes a 'home_feed impression', how to handle sessions with multiple impressions, and whether the 7-day window is rolling or fixed. Discuss time zone considerations and data freshness.

2. Identify denominator sessions

Write a CTE to select distinct session IDs that had at least one home_feed impression on each date. This forms the base population for the metric.

3. Identify numerator sessions

Write a CTE to select distinct session IDs that saw at least one impression from the shop ranked 5 or below on home_feed on that date. Ensure ranking is correctly interpreted (e.g., rank <= 5).

4. Compute daily score per shop

Join the numerator and denominator CTEs on date and shop, calculate the fraction as numerator count divided by denominator count, and output date, shop, score, numerator, and denominator.

5. Apply 7-day window aggregation

Use a window function to compute a rolling 7-day average of the daily score per shop, or aggregate the numerator and denominator over the window before dividing, depending on the desired interpretation.

Key Points to Mention

  • Use of CTEs for readability and modularity
  • Distinct session counting to avoid double-counting
  • Handling of ranking logic (e.g., rank <= 5)
  • Definition of denominator: sessions with at least one home_feed impression
  • Window functions for 7-day rolling calculation
  • Edge cases: sessions with no impressions, multiple shops, or ties in ranking

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

Q2

From the SVS query results, identify the top 3 shops by 7-day average SVS. If there are ties, break them by total home_feed impressions in the same window.

Product Analytics & MetricsData Modeling
Author's notes

Straightforward once the main query works.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the SVS metric definition and the query result schema, including how 7-day average is computed and whether the window is fixed or rolling. Then, write a SQL query that aggregates SVS over the 7-day window per shop, ranks shops by average SVS descending, and uses total home_feed impressions as a tiebreaker. Finally, validate the results and discuss potential edge cases like missing data or timezone issues.

Pro tip: Always confirm whether the 7-day average should be computed as a simple average of daily SVS values or as a weighted average based on impressions; the latter is often more appropriate for ratio metrics like SVS. Also, explicitly state your assumptions about the time window (e.g., last 7 days from today) to avoid ambiguity.

1. Clarify metric and schema

Ask clarifying questions about SVS definition, how 7-day average is calculated, and the structure of the SVS query results (columns, granularity). Confirm the time window and tiebreaker logic.

2. Aggregate SVS and impressions

Write a subquery or CTE to compute the 7-day average SVS per shop and sum home_feed impressions over the same window. Ensure proper filtering for the date range.

3. Rank and break ties

Use window functions (e.g., ROW_NUMBER() or RANK()) to order shops by average SVS descending, then by total impressions descending. Select the top 3.

4. Validate and interpret

Check for ties, missing data, or outliers. Discuss how the results might be used and any limitations (e.g., small sample sizes, seasonality).

Key Points to Mention

  • Definition of SVS and whether it's a ratio metric (e.g., success volume / impressions)
  • Handling of the 7-day window: fixed vs. rolling, and timezone considerations
  • Use of window functions for ranking and tiebreaking
  • Importance of total home_feed impressions as a tiebreaker and its business relevance
  • Data quality checks: nulls, zero impressions, or incomplete days
  • Potential need for weighted average if SVS is a ratio

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

Q3

The rank column can have gaps, meaning a session might have ranks 2, 4, 6 with no rank 1. Does your query still correctly capture top-5 visibility, or does it need adjustment?

Data ModelingTechnical Trade-offs
Author's notes

The condition rank <= 5 handles gaps automatically since it's a numeric comparison, not a positional one.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the definition of 'top-5 visibility'—whether it means the five highest-ranked sessions or sessions with rank ≤ 5. Then, analyze how gaps in the rank column affect the query's logic, particularly if it relies on rank values or row numbering. Finally, propose adjustments such as using DENSE_RANK or filtering by rank threshold to ensure correct capture.

Pro tip: Demonstrate awareness that rank gaps often signal missing data or business rules (e.g., deleted sessions), and that the choice between rank-based and row-number-based logic depends on the specific visibility metric. This shows you consider data context, not just syntax.

1. Clarify the definition of top-5 visibility

Ask whether 'top-5' means the five sessions with the highest ranks (regardless of rank values) or sessions with rank ≤ 5. This determines if gaps matter.

2. Examine the current query logic

Identify if the query uses ROW_NUMBER, RANK, DENSE_RANK, or a simple rank filter. Gaps affect ROW_NUMBER and RANK differently.

3. Assess impact of gaps

If using ROW_NUMBER, gaps don't affect the count of top-5 rows. If using RANK or filtering rank ≤ 5, gaps can cause fewer than 5 rows or include unintended rows.

4. Propose adjustments

If needed, switch to DENSE_RANK to ignore gaps, or use ROW_NUMBER with ORDER BY rank to get exactly 5 rows. Alternatively, filter by rank ≤ 5 if that's the business rule.

5. Validate with edge cases

Test with ranks like 2,4,6 and 1,3,5 to ensure the query returns the correct set under both interpretations.

Key Points to Mention

  • Difference between ROW_NUMBER, RANK, and DENSE_RANK in handling gaps.
  • The importance of clarifying business definition of 'top-5'.
  • How gaps can lead to fewer than 5 rows if filtering by rank ≤ 5.
  • Using ORDER BY rank with ROW_NUMBER to get exactly 5 rows regardless of gaps.
  • Potential data quality issues indicated by rank gaps.
  • Testing with edge cases to ensure correctness.

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

Q4

Identify two ways the SVS metric could be gamed or produce biased results given only the columns in this schema, and propose a SQL-only fix for each.

Product Analytics & MetricsRoot Cause AnalysisTechnical Trade-offs
Author's notes

This is where I felt least prepared.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify what SVS represents and identify its components from the schema. Then, systematically think about how each component could be manipulated or biased, and propose SQL-based fixes that address the root cause without requiring external data.

Pro tip: Frame your answer around data integrity and fairness, showing that you consider both technical and business implications. Mention that fixes should be scalable and maintainable.

1. Understand SVS and schema

Define SVS and list the relevant columns. Identify how SVS is calculated from these columns.

2. Identify gaming vectors

Brainstorm ways users or systems could artificially inflate or deflate SVS using only the available columns.

3. Identify bias sources

Consider how data collection or schema limitations could introduce bias into SVS.

4. Propose SQL fixes

For each issue, design a SQL-only solution (e.g., filtering, weighting, normalization) that mitigates the problem.

5. Validate and iterate

Suggest how to test the fixes and monitor for new gaming or bias patterns.

Key Points to Mention

  • Definition of SVS and its components from the schema
  • Specific gaming methods (e.g., repeated actions, selective reporting)
  • Bias from missing data, sampling, or time windows
  • SQL techniques: window functions, subqueries, CASE statements, aggregation filters
  • Importance of data validation and outlier detection
  • Trade-offs between simplicity and robustness of fixes

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