← Openai Interview Insights

Openai·Data Scientist·Take-home Assignment·Senior

Senior
May 2026

Summary

Got a take-home style SQL problem for a Data Scientist role at OpenAI, centered on analyzing a free trial A/B test from raw event logs. The schema was realistic and messy in the way production tables actually are, which I appreciated even if it made the metric definitions trickier to implement cleanly.

Questions Asked (2)

Q1

Given raw event log tables for experiment assignments, offer exposures, subscription lifecycle events, and app sessions, write SQL that outputs one row per variant showing assigned users, 7-day trial signups, signup rate, D30 retained users, and retention rate.

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

The metric definitions looked clean on paper but the SQL got complicated fast.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the grain and definitions: one row per variant, with assigned users as the denominator for signup rate and D30 retained users as the numerator for retention rate. Build a base table of assigned users per variant, then left join aggregated metrics from exposures, subscription events, and sessions, using conditional aggregation and date logic to compute 7-day trial signups and D30 retention.

Pro tip: Always state your assumptions about metric definitions (e.g., 7-day trial signup = trial started within 7 days of assignment; D30 retention = active on day 30 after signup) and mention that you would validate with a quick sanity check on counts before finalizing the query.

1. Clarify definitions and grain

Confirm what 'assigned users', '7-day trial signups', 'D30 retained users', and 'retention rate' mean, and ensure the output is one row per variant. Define the time windows and whether rates are per assigned user or per signup.

2. Build base assignment table

Select distinct user_id and variant from the experiment assignments table, filtering to the experiment of interest and the relevant assignment window. This forms the denominator for assigned users and signup rate.

3. Aggregate signup metrics

From subscription lifecycle events, identify trial signups within 7 days of assignment. Left join to the base table and count distinct users per variant to get 7-day trial signups, then compute signup rate as signups divided by assigned users.

4. Aggregate retention metrics

From app sessions, identify users active on day 30 after signup (or after assignment, depending on definition). Count distinct retained users per variant and compute retention rate as retained users divided by assigned users (or by signups).

5. Combine and format output

Join the aggregated metrics on variant, select the required columns, and ensure one row per variant. Use COALESCE to handle nulls and round rates appropriately.

Key Points to Mention

  • Define the denominator for each rate: assigned users for signup rate, and either assigned users or signups for retention rate—clarify which is expected.
  • Use LEFT JOINs from the assignment table to avoid dropping users with no events, and count distinct users to avoid duplicates from multiple events.
  • Apply date filters correctly: trial signup within 7 days of assignment, and D30 retention as activity on day 30 after signup (or assignment).
  • Consider exposure data: optionally filter to users who were actually exposed to the experiment, but note that assigned users is the typical denominator for intent-to-treat analysis.
  • Handle edge cases: users with multiple assignments, missing events, and timezone considerations for date calculations.
  • Use conditional aggregation (e.g., SUM(CASE WHEN ... THEN 1 ELSE 0 END)) or subqueries to compute metrics in a single pass where possible.

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

Q2

What does an upstream data pipeline need to contain to make these A/B test metrics reliably computable?

A/B Testing & ExperimentationSystem DesignRoot Cause Analysis
Author's notes

Basically asking what could go wrong before the SQL even runs.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by framing the pipeline as the foundation for trustworthy experimentation, then walk through the data requirements layer by layer: ingestion, transformation, and serving. Emphasize that reliability comes from explicit handling of assignment, exposure, and metric definitions, not just raw data volume.

Pro tip: Always discuss data quality checks and idempotency in the pipeline—these are often overlooked but critical for reproducible A/B test results. Mentioning how you'd handle late-arriving data or duplicate events shows operational maturity.

1. Define the experimental unit and assignment

Ensure the pipeline captures and preserves the unit of randomization (e.g., user_id, session_id) and the variant assignment consistently across all events. This is the backbone for any valid comparison.

2. Capture exposure and trigger events

Log when a unit is actually exposed to the treatment and any trigger events that qualify them for analysis. Without this, you risk dilution or misattribution of effects.

3. Standardize metric computation

Implement clear, versioned definitions for each metric (e.g., click-through rate, conversion) and compute them at the unit level before aggregation. This avoids Simpson's paradox and ensures consistency.

4. Ensure data quality and completeness

Add validation checks for missing values, duplicates, and outliers; handle late-arriving data with watermarks or reprocessing. This guarantees that metrics are computed on a clean, complete dataset.

5. Enable reproducibility and lineage

Store raw data immutably, version transformation logic, and track data lineage so any metric can be recomputed exactly as before. This is essential for debugging and trust.

Key Points to Mention

  • Unique identifiers for users and sessions to join events correctly
  • Variant assignment logging with timestamp and consistency checks
  • Exposure event tracking to measure actual treatment effect
  • Metric definitions with clear numerator/denominator and aggregation level
  • Data quality monitoring: completeness, freshness, and anomaly detection
  • Idempotent and replayable pipeline for backfilling and corrections

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