← Uber Interview Insights

Uber·Data Scientist·Technical Phone Screen·Senior

Senior
May 2026

Summary

Uber DS interview, heavy on SQL and stats. Three questions, all technical, no fluff. The kind of session where you're writing window functions and explaining CUPED variance reduction back to back and hoping your brain doesn't stall out.

Questions Asked (3)

Q1

For a specific experiment, write a SQL query that computes a 7-day rolling median of shown ETA and the daily request-to-completion conversion rate per city, across a date range. You need to generate a full date spine so days with zero requests still appear, restrict to riders who signed up before a cutoff date, and handle time zones by truncating timestamps at UTC midnight.

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

The date spine part is what got me.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the schema and definitions (e.g., tables for requests, completions, riders, cities; how ETA is stored). Then outline a query plan: generate a date spine, join aggregated daily metrics per city, compute rolling medians and conversion rates, and apply filters for rider signup cutoff and UTC truncation. Finally, write the SQL with CTEs for readability and test edge cases.

Pro tip: Mention that rolling medians are computationally expensive and suggest using window functions with PERCENTILE_CONT or approximate methods if the dataset is large, and always validate the date spine against the actual data to avoid missing days.

1. Clarify requirements and schema

Ask about table structures, definitions of 'shown ETA', 'request-to-completion conversion rate', and the cutoff date. Confirm whether the rolling median is per city or overall, and the exact date range.

2. Generate date spine and filter riders

Create a date spine covering the full range using GENERATE_DATE_ARRAY or a recursive CTE. Filter riders to those who signed up before the cutoff date, and truncate timestamps to UTC midnight for grouping.

3. Aggregate daily metrics per city

Join requests and completions to the date spine, compute daily request counts, completion counts, and average shown ETA per city per day. Ensure days with zero requests are included via left join.

4. Compute rolling median and conversion rate

Use window functions to calculate the 7-day rolling median of shown ETA and the daily conversion rate (completions/requests) per city. Handle nulls and division by zero.

5. Finalize and validate query

Assemble the query with CTEs, add comments, and consider performance (indexes, partitioning). Validate results by checking a few cities and dates manually.

Key Points to Mention

  • Date spine generation using GENERATE_DATE_ARRAY or recursive CTE to fill missing dates.
  • Filtering riders by signup date cutoff before aggregation.
  • Time zone handling: truncating timestamps to UTC midnight (e.g., DATE_TRUNC(timestamp, DAY)).
  • Rolling median calculation using window functions (e.g., PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY eta) OVER (PARTITION BY city ORDER BY date ROWS BETWEEN 6 PRECEDING AND CURRENT ROW)).
  • Conversion rate calculation: completions divided by requests, with careful handling of zero requests.
  • Performance considerations: indexing, partitioning, and potential use of approximate percentiles for large datasets.

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

Q2

Write a SQL query to estimate a difference-in-differences conversion uplift at the city level, comparing treated vs control riders across a pre-period and a post-period. Riders can appear in both treatment and control across different trips, so the exposure label should be at the trip level, not the rider level.

A/B Testing & ExperimentationProduct Analytics & Metrics
Author's notes

The trip-level exposure thing tripped me up.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the experiment design and define conversion at the trip level, ensuring the exposure label is assigned per trip. Then, aggregate conversion rates by city, treatment group, and period, and compute the difference-in-differences estimator using SQL. Finally, consider statistical significance and potential confounders.

Pro tip: Always check for balance in pre-period trends between treatment and control groups; if they differ, the DiD estimate may be biased. Also, consider clustering standard errors at the city level to account for within-city correlation.

1. Clarify experiment design and define metrics

Confirm the treatment assignment mechanism, the definition of conversion (e.g., ride completed, booking made), and the pre/post periods. Ensure exposure is at the trip level, not rider level.

2. Aggregate data by city, group, and period

Write a subquery to compute the conversion rate for each city, treatment group (treated/control), and period (pre/post). This involves counting conversions and total trips.

3. Compute difference-in-differences

Use conditional aggregation or self-joins to calculate the DiD estimate: (treated_post - treated_pre) - (control_post - control_pre) for each city, then average across cities if needed.

4. Assess statistical significance and robustness

Optionally, compute standard errors or confidence intervals, and check for pre-period parallel trends. Consider sensitivity analyses.

Key Points to Mention

  • Trip-level exposure assignment to avoid contamination from riders appearing in both groups.
  • Definition of conversion metric and consistent application across periods and groups.
  • Aggregation at the city level to estimate city-specific uplift, then possibly pooling.
  • Difference-in-differences formula: (Y_treated_post - Y_treated_pre) - (Y_control_post - Y_control_pre).
  • Parallel trends assumption and its importance for causal inference.
  • Potential confounders like seasonality, city-specific shocks, and clustering of standard errors.

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

Q3

In Python pseudocode, implement CUPED-adjusted conversion at the rider level using pre-period conversion as the covariate. Estimate theta as cov(Y, X) / var(X), compute the adjusted outcome, then estimate the treatment vs control uplift with cluster-robust standard errors at the rider or city level.

A/B Testing & ExperimentationProduct Analytics & Metrics
Author's notes

I know CUPED conceptually but writing the cluster-robust SE part from scratch in pseudocode is awkward.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clearly defining the rider-level data structure and the CUPED adjustment formula, then walk through the pseudocode step by step, emphasizing the estimation of theta and the computation of adjusted outcomes. Finally, explain how to compute cluster-robust standard errors at the rider or city level to account for correlation within clusters.

Pro tip: When implementing CUPED, always validate that the pre-period covariate is balanced between treatment and control groups; if not, consider using a regression adjustment or stratification. Also, for cluster-robust standard errors, use the cluster-robust variance estimator (e.g., CR2) to avoid underestimating uncertainty when clusters are few.

1. Data Preparation and Covariate Definition

Load rider-level data with treatment assignment, pre-period conversion (X), and post-period conversion (Y). Ensure X is measured before the experiment and is unaffected by treatment.

2. Estimate Theta

Compute theta as the sample covariance between Y and X divided by the sample variance of X. This can be done using numpy or pandas functions.

3. Compute Adjusted Outcome

For each rider, calculate the CUPED-adjusted outcome: Y_adj = Y - theta * (X - mean(X)). This removes the variance explained by the pre-period covariate.

4. Estimate Treatment Effect

Calculate the difference in mean adjusted outcomes between treatment and control groups. This is the CUPED-adjusted uplift estimate.

5. Cluster-Robust Standard Errors

Compute standard errors for the uplift using cluster-robust methods at the rider or city level. Use libraries like statsmodels or implement the formula manually, clustering by rider or city.

Key Points to Mention

  • CUPED reduces variance by using pre-experiment data as a covariate, improving sensitivity.
  • Theta is estimated as cov(Y, X) / var(X) and should be computed on the entire sample or control group only.
  • Adjusted outcome formula: Y_adj = Y - theta * (X - mean(X)).
  • Cluster-robust standard errors account for within-cluster correlation, which is crucial when randomizing at rider or city level.
  • Use appropriate libraries (e.g., statsmodels, numpy) for efficient computation.
  • Validate assumptions: pre-period covariate should be independent of treatment and predictive of outcome.

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