← Meta Interview Insights

Meta·Data Scientist·Technical Phone Screen·Senior

Senior
Jun 2026Remote

Summary

SQL-heavy data science screen at Meta focused entirely on marketplace metrics. One long question that spiraled into about five sub-questions once you thought you were done. The kind of interview where you realize halfway through that knowing SQL isn't the same as knowing how to think about SQL at scale.

Questions Asked (5)

Q1

You own a 'shop visibility' KPI for a marketplace. Define a precise metric for it and write SQL to compute it over a 7-day window. You need two definitions: (A) visibility_rate as unique US users who saw at least one active product from a shop divided by total active US users, and (B) impression_share as impressions of a shop's active products divided by total impressions of all active products. Exclude deactivated products, deduplicate multiple impressions of the same product by the same user within a session, and restrict active users to those with at least one session in the window. Return shop_id, visibility_rate, impression_share, unique_viewers, active_users, window_start, and window_end.

Product Analytics & MetricsData Modeling
Author's notes

The metric definition part felt fine at first.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the metric definitions and edge cases (e.g., active products, session deduplication, active users) to ensure alignment. Then outline the SQL logic step by step, using CTEs to compute unique viewers, active users, and impressions separately before joining. Finally, present the final query with clear comments and explain how you would validate the results.

Pro tip: Mention that you would handle session deduplication by grouping by user, product, and session_id, and note that the denominator for visibility_rate should be active users who had at least one session in the window, not all users. Also, highlight the importance of filtering to active products and active users before aggregation to avoid skewing the metrics.

1. Clarify Definitions and Assumptions

Restate the metric definitions and confirm edge cases: what constitutes an 'active product', how sessions are defined, and whether 'active US users' means users with at least one session in the window. This ensures you and the interviewer are aligned before writing SQL.

2. Identify Relevant Tables and Fields

Assume tables like `impressions` (user_id, product_id, shop_id, session_id, timestamp, country), `products` (product_id, shop_id, is_active), and `sessions` (user_id, session_id, timestamp, country). Specify that you'll filter for US users and the 7-day window.

3. Compute Unique Viewers and Active Users

Use CTEs to calculate unique viewers per shop (distinct users who saw at least one active product) and total active users (distinct users with at least one session in the window). Ensure deduplication by session for impressions.

4. Compute Impressions and Impression Share

Calculate total impressions per shop (after deduplicating multiple impressions of the same product by the same user within a session) and total impressions across all shops. Then compute impression_share as the ratio.

5. Assemble Final Query and Validate

Join the CTEs to produce the final output with shop_id, visibility_rate, impression_share, unique_viewers, active_users, window_start, and window_end. Discuss validation steps, such as checking for NULLs or ensuring rates are between 0 and 1.

Key Points to Mention

  • Define 'active product' as a product that is not deactivated (is_active = true) and belongs to the shop.
  • Deduplicate impressions by grouping by user_id, product_id, and session_id to count only one impression per product per user per session.
  • Restrict active users to those with at least one session in the 7-day window and from the US.
  • Use window functions or subqueries to compute total impressions across all active products for the denominator of impression_share.
  • Ensure the 7-day window is clearly defined (e.g., using DATE_SUB or BETWEEN) and applied consistently to both impressions and sessions.
  • Consider performance implications: filter early, use appropriate indexes, and avoid cross joins.

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

Q2

How would you parameterize the same shop visibility query per surface, for example separating feed impressions from shoppage impressions?

Product Analytics & MetricsTechnical Trade-offs
Author's notes

Pretty easy follow-up once the main query is done.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the goal: to measure shop visibility consistently across surfaces while allowing surface-specific nuances. Propose a parameterized query design where surface is a dimension, and define surface-specific visibility metrics (e.g., impression share) with shared logic but adaptable filters. Emphasize the trade-off between standardization and flexibility, and suggest a scalable implementation using a config-driven approach.

Pro tip: Mention that you would align with cross-functional partners (e.g., product, engineering) to define surface-specific visibility definitions early, and use a single source of truth with parameterized views to avoid metric drift. Also, highlight the importance of testing the parameterization with A/B tests or backfilling to ensure consistency.

1. Clarify requirements and definitions

Ask clarifying questions to understand what 'shop visibility' means for each surface (feed vs. shoppage) and what metrics are needed. Confirm if the goal is to compare surfaces or to monitor each independently.

2. Design parameterized query structure

Outline a query that takes surface as a parameter, with conditional logic or separate CTEs for each surface's impression logic. Use a unified schema with surface-specific filters and aggregations.

3. Define surface-specific metrics and dimensions

Specify how visibility metrics (e.g., impression rate, click-through rate) are calculated per surface, ensuring denominators and time windows are appropriate. Include dimensions like user segment, time, and surface.

4. Implement with scalability and maintainability

Suggest using a config table or dbt macros to manage surface parameters, enabling easy addition of new surfaces. Discuss performance considerations (e.g., partitioning, indexing) and data governance.

5. Validate and iterate

Propose validation steps: compare parameterized results with existing surface-specific queries, run sanity checks, and gather feedback from stakeholders. Iterate on definitions as needed.

Key Points to Mention

  • Parameterization approach: using a surface dimension or config-driven query
  • Surface-specific visibility definitions (e.g., feed impressions vs. shoppage impressions)
  • Trade-offs between standardization and flexibility
  • Scalability and maintainability (e.g., dbt macros, config tables)
  • Validation and consistency checks across surfaces
  • Stakeholder alignment on metric definitions

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

Q3

How would you handle late-arriving impressions and bot traffic in this pipeline?

System DesignTechnical Trade-offs
Author's notes

Late arrivals I had a decent answer for: use an ingestion timestamp separate from the event timestamp, and run a daily backfill job that reprocesses any events where the ingestion lag exceeded some threshold.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by acknowledging that late-arriving impressions and bot traffic are inevitable in large-scale data pipelines, and that the goal is to balance data completeness with timeliness while ensuring data quality. Then, describe a multi-layered approach: real-time filtering for obvious bots, a streaming architecture with windowing and watermarks to handle late data, and a batch reconciliation process to correct any inaccuracies. Finally, emphasize the importance of monitoring and iterating on bot detection models to adapt to evolving threats.

Pro tip: Quantify the trade-offs: for example, explain how you'd measure the impact of late data on key metrics and set acceptable thresholds for data loss vs. latency, showing you understand business implications. Also, mention that bot traffic can be handled both at ingestion (e.g., rule-based filters) and post-hoc (e.g., ML models), and that you'd use a feedback loop to improve detection.

1. Define requirements and SLAs

Clarify what latency and accuracy are acceptable for the use case. For example, real-time dashboards may tolerate some late data, while billing systems require complete accuracy.

2. Design for late data

Use a streaming framework like Apache Flink or Spark Structured Streaming with event-time processing, watermarks, and allowed lateness. Store late events in a durable queue (e.g., Kafka) and reprocess them in batch.

3. Implement bot detection

Apply rule-based filters (e.g., user-agent, IP blacklists) at ingestion for immediate mitigation, and train ML models on historical data to score and filter bot traffic in near real-time.

4. Reconcile and correct

Run periodic batch jobs to reprocess data with late arrivals and updated bot labels, ensuring the final dataset is accurate. Use a lambda architecture or kappa architecture with replayable logs.

5. Monitor and iterate

Set up monitoring for data freshness, bot detection precision/recall, and pipeline health. Use A/B testing to evaluate bot detection models and adjust thresholds based on feedback.

Key Points to Mention

  • Event-time vs. processing-time semantics and watermarks for handling late data
  • Trade-offs between latency, cost, and accuracy in streaming vs. batch processing
  • Techniques for bot detection: rule-based, ML-based, and hybrid approaches
  • Data quality metrics and monitoring (e.g., data completeness, bot rate)
  • Architectural patterns: lambda architecture, kappa architecture, and their pros/cons
  • Business impact: how late data and bots affect key metrics like ad revenue and user engagement

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

Q4

What indexes or table clustering strategies would you use to make this query efficient at over a billion rows?

System DesignAlgorithms & Data Structures
Author's notes

Cluster the impressions table by date and then by product_id so the 7-day filter prunes partitions and the join to products is localized.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the query pattern and access paths, then propose a partitioning and clustering strategy that aligns with how the data is filtered and joined. Discuss specific index types (e.g., columnar sort keys, composite indexes) and how they reduce scanned data at scale. Finally, address trade-offs and alternatives like materialized views or pre-aggregation.

Pro tip: At Meta's scale, partitioning and clustering often outperform traditional B-tree indexes because they enable partition pruning and reduce I/O. Mention that you'd validate the strategy with EXPLAIN plans and query profiling on a sample dataset before rolling out.

1. Clarify the query and workload

Ask about the query's filters, joins, aggregations, and expected concurrency. Identify the most selective columns and whether the query is point-lookup or analytical.

2. Choose partitioning strategy

Partition by a high-cardinality column commonly used in filters (e.g., date, user_id) to enable partition pruning. Consider range or hash partitioning based on data distribution and query patterns.

3. Select clustering/sort keys

Within each partition, cluster or sort by columns used in WHERE, JOIN, or GROUP BY to co-locate related data. For columnar stores, use sort keys; for row stores, consider composite indexes.

4. Evaluate index types and trade-offs

Discuss B-tree, bitmap, or inverted indexes as appropriate, but note that at billion-row scale, partitioning + clustering often suffices. Consider covering indexes to avoid table lookups.

5. Validate and iterate

Propose testing with EXPLAIN plans, measuring scan sizes, and monitoring performance. Be ready to adjust based on real query patterns and data skew.

Key Points to Mention

  • Partition pruning to reduce data scanned
  • Clustering/sort keys for co-locating related data
  • Composite indexes on frequently filtered columns
  • Covering indexes to avoid expensive lookups
  • Trade-offs between index maintenance overhead and query speed
  • Alternatives like materialized views or pre-aggregated tables

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

Q5

How would you adapt this query for incremental daily jobs and backfills?

Data ModelingTechnical Trade-offs
Author's notes

For incremental runs: process only the new day's partition and append to an aggregated results table.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the query's purpose and the data volume, then propose a partitioned incremental strategy with idempotent writes and a separate backfill mechanism. Emphasize trade-offs between cost, latency, and correctness, and show how you'd validate results and handle late-arriving data.

Pro tip: Demonstrate maturity by explicitly separating the incremental path from the backfill path, and mention how you'd use a parameterized date range to avoid code duplication while keeping backfills isolated from production.

1. Clarify requirements and constraints

Ask about data volume, update frequency, SLA, and whether the query must handle late-arriving or corrected data. Confirm the target storage (e.g., partitioned table) and downstream dependencies.

2. Design incremental logic

Partition by date and process only the latest partition(s) using a watermark or max date. Use idempotent writes (e.g., MERGE or INSERT OVERWRITE) to allow safe re-runs and handle duplicates.

3. Design backfill mechanism

Parameterize the query with start and end dates so the same logic can run for any historical range. Isolate backfills to a separate job or queue to avoid impacting daily SLAs.

4. Address trade-offs and optimizations

Discuss partitioning, clustering, and incremental aggregation to reduce cost. Consider using a temporary table or staging area for backfills to minimize recomputation.

5. Plan validation and monitoring

Define checks for row counts, freshness, and data quality. Set up alerts for failures and compare backfill results against a known baseline to ensure correctness.

Key Points to Mention

  • Partitioning by date and using a watermark to track processed data
  • Idempotent writes (e.g., MERGE, INSERT OVERWRITE) to handle re-runs and duplicates
  • Parameterized date ranges to reuse the same query for daily and backfill jobs
  • Isolation of backfill jobs from incremental jobs to avoid resource contention
  • Handling late-arriving data with a lookback window or reprocessing recent partitions
  • Cost and performance trade-offs: full refresh vs. incremental, and using staging tables for backfills

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