Daily Retention Curves With a Date Spine for Sparse Meta AI Cohorts

Last updated: November 29, 2026

Quick Overview

For the Meta AI app, produce a long table with one row per signup date and day offset 0 through 28 showing users active and the retention rate, including explicit zero rows for offsets where nobody returned and excluding offsets not yet observed.

Meta
Data Manipulation (SQL/Python)
Data Scientist
Meta
November 29, 2026
Data Scientist
Onsite
Data Manipulation (SQL/Python)
Hard

0

0

0 solved


For the Meta AI app, produce a long table with one row per signup date and day offset 0 through 28 showing users active and the retention rate, including explicit zero rows for offsets where nobody returned and excluding offsets not yet observed.

New Meta products like the standalone Meta AI app start with small, noisy cohorts where many cells are zero, and dashboards break when those rows are missing rather than zero. This onsite question checks generating a spine with `SEQUENCE` and `UNNEST`, joining sparse counts onto it, and censoring correctly.

What the Interviewer Expects
  • Generate offsets 0..28 with SEQUENCE and UNNEST
  • Cross join cohorts with offsets and then filter immature cells
  • Left join sparse active counts onto the spine
  • COALESCE missing counts to 0
  • Keep cohort size for weighting
Key Topics to Cover
date spine
SEQUENCE UNNEST
sparse data
retention curve
censoring
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
  • How would you compute a pooled curve across all cohorts correctly?
  • How would you smooth noisy small cohorts?
  • How would this differ if the table was very large and pre-aggregated daily?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice SQL Problems
Sample Answer
Clarify the Data

ai_users(user_id, signup_date) and ai_activity(user_id, ts). Offsets are days since signup. Last observed date is max(ts) cast to date. Engine is Presto/Trino....

Approach

Count cohort sizes. Compute sparse counts of distinct active users per (signup_date, offset). Build the spine as cohort x offsets, keep only offsets where signup_date + offset <= last_day, then le...


Submit Your Answer
Markdown supported