DoorDash Staff Data Scientist Interview Preparation Guide
DoorDash's Staff Data Scientist interview process is comprehensive and multi-stage, designed to assess technical depth, business acumen, and leadership capabilities. The process typically spans 4-6 weeks and includes a recruiter screening, one technical phone screen, and six onsite rounds covering SQL analytics, machine learning, product metrics & A/B testing, data infrastructure & systems design, behavioral & leadership competencies, and a technical take-home project. For Staff level candidates, the emphasis extends beyond technical execution to strategic thinking, mentorship, cross-functional influence, and the ability to drive high-impact initiatives across the organization.
Interview Rounds
Recruiter Screening
What to Expect
Initial screening conversation (15-30 minutes) with a recruiter followed by a deeper technical discussion (20-30 minutes) with a hiring manager or senior data scientist. The recruiter assesses your career trajectory, motivation for the Staff role, and overall alignment with DoorDash's culture and mission. The second discussion with a technical leader explores your background in depth, examining 2-3 key projects where you've demonstrated leadership, mentorship, and cross-functional impact. This round establishes baseline qualifications and cultural fit.
Tips & Advice
Research DoorDash thoroughly: understand their business model, recent product initiatives (e.g., Project Dash, expansion into new markets or services), leadership team, and stated company values. Prepare 2-3 compelling stories using the STAR framework that highlight: (1) a project where data insights directly influenced company strategy or product direction, (2) mentorship of junior data scientists and their career progression, and (3) how you navigated cross-functional complexity or organizational ambiguity to deliver results. Articulate your motivation for Staff level clearly—it should reflect both technical aspiration and readiness for the expanded scope of mentorship and influence. Connect your experience to DoorDash's specific challenges: real-time optimization at scale, marketplace dynamics, logistics efficiency. Ask thoughtful questions about team structure, current initiatives, and how success is measured in the role.
Focus Topics
Cross-Functional Influence & Organizational Navigation
Describe a situation where you influenced product, engineering, or business teams without direct authority. Explain your approach to building consensus, handling disagreements, and driving decisions collaboratively. Show awareness of organizational dynamics and politics.
Practice Interview
Study Questions
Career Progression to Staff Level & Strategic Motivation
Articulate your journey to Staff level with specific inflection points where you took on leadership, expanded scope, and demonstrated impact. Explain what attracts you to DoorDash's data science problems at this stage of your career. Connect your experience to the role's focus areas: marketplace optimization, logistics, customer/merchant retention, dynamic pricing, or growth.
Practice Interview
Study Questions
DoorDash Business Model & Strategic Data Opportunities
Demonstrate deep understanding of DoorDash's three-sided marketplace, key metrics across each stakeholder group (customer acquisition cost, merchant churn, dasher utilization), and data science applications in pricing, logistics, growth, and retention. Show awareness of competitive dynamics and DoorDash's strategic priorities.
Practice Interview
Study Questions
Mentorship & Team Development Track Record
Share concrete examples of junior data scientists you've mentored, how you helped them grow (skill development, project ownership, career advancement), and what approach you take to coaching. Discuss how you balance providing guidance with fostering independence.
Practice Interview
Study Questions
Technical Phone Screen
What to Expect
A 60-minute technical phone screen conducted by a senior data scientist or technical hiring manager using a shared coding environment like CodePair. This round focuses on SQL fluency, analytical reasoning, and real-time problem-solving. You'll solve 1-2 moderately complex SQL problems simulating realistic DoorDash scenarios (e.g., customer cohort analysis, order metrics aggregation, merchant performance evaluation). For Staff level, interviewers evaluate not just correctness but code quality, optimization thinking, and your ability to articulate trade-offs and ask clarifying questions that demonstrate strategic reasoning.
Tips & Advice
Write clean, efficient SQL that prioritizes both readability and performance. Use Common Table Expressions (CTEs) to break complex logic into digestible pieces, employ window functions strategically, and optimize joins carefully. Before coding, ask clarifying questions about data schema, expected volume, and performance requirements—this demonstrates maturity. For Staff level, interviewers will assess your ability to think about scalability and maintainability. Optimize queries with awareness of indexing and execution plans, but don't over-optimize at the expense of clarity. Be prepared to explain trade-offs: when to use a simple loop vs. a complex window function, when denormalization makes sense, how to handle late-arriving or duplicate data. If requirements change mid-problem, adapt gracefully and explain your thought process. Discuss how you'd monitor this query in production and what guardrails you'd implement.
Focus Topics
Query Optimization & Execution Planning
Understand query execution plans, indexing strategies, and how to diagnose performance bottlenecks. Learn to use EXPLAIN/ANALYZE to inspect query performance. Think about join order, filtering early in the pipeline, and when to pre-aggregate data. Discuss trade-offs between normalized and denormalized schemas.
Practice Interview
Study Questions
Problem Decomposition & Strategic Questioning
For ambiguous problems, ask clarifying questions about data structure, expected volume, latency requirements, and business context. Break down complex requirements, propose an approach, and discuss edge cases. Show ability to balance simplicity with accuracy.
Practice Interview
Study Questions
Advanced SQL: Window Functions & Complex Aggregations
Master window functions (ROW_NUMBER, RANK, DENSE_RANK, SUM OVER, LAG, LEAD, etc.) for solving ranking, running total, and sequential analysis problems. Combine with GROUP BY, HAVING, and JOINs to handle multi-level aggregations. Solve realistic scenarios like cohort retention, customer lifetime value within cohorts, and time-series analysis.
Practice Interview
Study Questions
Onsite Round 1: SQL Analytics & Metrics Deep Dive
What to Expect
A 75-90 minute onsite round focused on complex analytical problems using realistic DoorDash data. You'll write SQL to answer nuanced business questions, potentially design metrics dashboards, and communicate findings to stakeholders. The interviewer may present an intentionally vague problem (e.g., 'Analyze why customer engagement declined') requiring you to propose metrics, construct queries, validate results, and derive business recommendations. For Staff level, evaluation extends beyond technical correctness to your strategic thinking, data quality awareness, and ability to translate findings into actionable business insights.
Tips & Advice
Approach each problem with structure: clarify requirements, propose key metrics, design your analytical approach, execute SQL queries, validate results, and summarize findings with business implications. For Staff level, demonstrate strategic thinking by discussing how you'd operationalize the metric (instrument it in production, define SLAs, set up monitoring), handle edge cases (data quality issues, time zone considerations, null handling), and scale the analysis. Be prepared to discuss trade-offs between simplicity and rigor. Consider how your findings would be communicated to different audiences: executives, product managers, engineers. Validate assumptions: check data distribution, look for outliers, confirm numbers make sense. If time permits, propose follow-up analyses that would deepen understanding. Throughout, show that you think about business context—why this metric matters, what decisions it informs, what actions might result.
Focus Topics
Data Quality Validation & Integrity Checks
Identify potential data quality issues: duplicates, null values, late-arriving data, schema mismatches, outliers indicating data problems. Propose validation checks and discuss how to handle edge cases. Communicate caveats and assumptions clearly to stakeholders.
Practice Interview
Study Questions
Time-Series Decomposition & Trend Analysis
Analyze time-series data to identify trends, seasonality, and anomalies. Calculate moving averages, year-over-year comparisons, and day-of-week effects. Discuss how to isolate signal from noise and understand drivers of changes. Use SQL window functions to compute these metrics efficiently.
Practice Interview
Study Questions
DoorDash Key Metrics & KPI Design
Deep mastery of DoorDash's core metrics across customer, merchant, and dasher domains: Customer Acquisition Cost (CAC), Lifetime Value (LTV), churn rate, repeat order frequency, Average Order Value (AOV), Gross Merchandise Value (GMV), merchant retention, dasher acceptance rate, on-time delivery rate, cancellation rate. Understand how each metric relates to business strategy and when to dig deeper with segmentation or cohort analysis.
Practice Interview
Study Questions
Cohort Analysis & Retention Patterns
Master cohort analysis techniques: segment users/merchants by acquisition date or cohort, calculate retention curves over time, identify churn inflection points, and compute cohort-level LTV. Understand how to control for seasonal effects and isolate cohort-specific trends. Use this to identify acquisition quality trends or retention levers.
Practice Interview
Study Questions
Onsite Round 2: Machine Learning & Statistical Modeling
What to Expect
A 60-90 minute round assessing your machine learning design skills and statistical reasoning. You'll be presented with a business problem (e.g., predicting delivery time, customer churn, fraud detection) and expected to propose an end-to-end modeling solution. This includes problem formulation, data strategy, feature engineering, model selection, evaluation strategy, and production considerations. The interviewer will probe your understanding of evaluation metrics, trade-offs, and how models integrate with business decisions. For Staff level, the emphasis is on architectural thinking, mentorship capability, and navigating ambiguity in real-world ML challenges.
Tips & Advice
Structure your response to show end-to-end thinking: (1) Problem formulation—define the prediction task, loss function, and business context; (2) Data strategy—what training data would you use, how would you handle time leakage or distribution shift; (3) Features—propose domain-aware features and discuss engineering at scale; (4) Model selection—justify your choice (linear model for interpretability, tree-based for performance, neural net for complexity) based on constraints; (5) Evaluation—propose metrics that align with business goals, discuss how you'd validate in production; (6) Deployment—discuss latency/throughput trade-offs, monitoring, and how model predictions integrate with business systems. For Staff level, emphasize your ability to think about real-world challenges: class imbalance, model drift, fairness, communication of uncertainty to stakeholders. Be prepared to discuss trade-offs explicitly. Show that you've thought about how to mentor junior team members on these concepts.
Focus Topics
Model Validation, Monitoring & Production Considerations
Discuss rigorous validation strategies: hold-out test sets, cross-validation, and temporal validation for time-series data. Understand how to detect model drift in production and retrain strategies. Discuss latency/throughput constraints in serving models. Address how to communicate model uncertainty and limitations to stakeholders.
Practice Interview
Study Questions
Model Selection & Complexity Trade-offs
Justify model choice based on interpretability, performance, latency, and maintenance requirements. Discuss when a simple linear model suffices vs. when tree-based or neural network approaches are justified. Understand regularization techniques (L1/L2, early stopping, dropout) to prevent overfitting and improve generalization.
Practice Interview
Study Questions
End-to-End ML System Design for DoorDash Use Cases
Design complete ML solutions for business problems: delivery time prediction (enabling customer eta expectations and dasher efficiency), customer churn prediction (identifying at-risk users for retention), demand forecasting (optimizing inventory and supply), fraud detection (protecting marketplace), or dynamic pricing (optimizing revenue). Walk through problem formulation, data collection strategy, feature engineering, model selection, evaluation approach, and production deployment considerations.
Practice Interview
Study Questions
Feature Engineering & Domain Expertise Integration
Engineer features that capture domain knowledge: for delivery time prediction, features like historical dasher performance, traffic patterns, merchant prep time; for churn, user engagement signals, order frequency, price sensitivity. Discuss how to handle feature engineering at scale, manage feature interactions, and maintain reproducibility. Discuss feature selection and avoiding overfitting.
Practice Interview
Study Questions
Evaluation Metrics & Business Trade-offs
Select appropriate evaluation metrics based on business context: precision vs. recall trade-offs for fraud (false positives costly vs. false negatives costly), RMSE/MAE for regression, and business-aligned metrics (e.g., improved dasher utilization). Justify metric choices and discuss threshold selection for classification models. Understand how to communicate model performance to non-technical stakeholders.
Practice Interview
Study Questions
Onsite Round 3: Product Metrics & A/B Testing
What to Expect
A 60-75 minute round focused on experimental design and product analytics thinking. You'll be asked to design an A/B test for a hypothetical DoorDash feature or change. The interviewer will present a vague product scenario (e.g., 'We want to increase customer retention by launching a loyalty program') and expect you to propose a rigorous experimental design, including hypothesis, metrics, randomization strategy, sample size calculation, and interpretation of results. For Staff level, the emphasis is on methodological rigor, ability to handle complex experimental scenarios (network effects, market-level interference), and translating experimental findings into product strategy.
Tips & Advice
Approach experiment design systematically: (1) Hypothesis—clearly state what you're testing and expected direction of effect; (2) Success metrics—define primary metric aligned with business goal and guardrail metrics to catch negative side effects; (3) Unit of randomization—decide whether to randomize at user level, market level, or other (discuss why); (4) Sample size calculation—estimate effect size, power, and minimum sample needed (often 80% power, 95% confidence); (5) Duration & ramp—propose experiment duration and how you'd ramp treatment; (6) Analysis plan—describe statistical tests and how you'd interpret results. For Staff level, go deeper: discuss confounders and how to handle them, address potential network effects (e.g., if some dashers are in same market), discuss how long to run experiment (beware of peeking), and consider heterogeneous treatment effects across segments. Show strategic thinking by connecting experimental findings to product decisions. Be prepared to discuss trade-offs between statistical rigor and speed.
Focus Topics
Complex Experimental Scenarios & Edge Cases
Handle real-world complexity: network effects (one dasher's behavior affects others), marketplace interactions (customer-merchant matches), treatment interference (control and treatment units affecting each other), and time lag for impact realization. Discuss when market-level randomization is needed vs. user-level. Address heterogeneous treatment effects across segments.
Practice Interview
Study Questions
Statistical Significance, Power Analysis & Multiple Testing
Master p-values, confidence intervals, Type I and II errors, and statistical power. Calculate sample sizes for detecting given effect sizes. Understand multiple testing corrections (Bonferroni, FDR) when running many tests. Discuss issues like peeking (early stopping) and how to avoid false conclusions.
Practice Interview
Study Questions
Metric Definition for Product Features & Strategic Alignment
For a proposed feature, define primary metrics (e.g., user engagement, retention, revenue impact), secondary metrics (guardrails), and how to measure them. Align metrics with strategic goals. Consider lag effects (how long until impact is visible) and business trade-offs (short-term revenue vs. long-term engagement).
Practice Interview
Study Questions
A/B Test Design & Hypothesis Formulation
Design rigorous experiments including clear hypothesis, definition of test and control groups, randomization strategy, sample size estimation, and duration. Define primary success metric and guardrail metrics (to catch unintended consequences). Consider minimum detectable effect (MDE) and statistical power (typically 80%). Discuss practical constraints like experiment cost and time-to-decision.
Practice Interview
Study Questions
Onsite Round 4: Data Infrastructure & Systems Thinking
What to Expect
A 60-75 minute round assessing your understanding of data infrastructure, pipelines, and systems design at scale. You'll discuss how to architect data systems that support analytics and ML: data collection and ingestion, transformation and aggregation, storage strategies, real-time vs. batch processing, and data quality assurance. The interviewer may ask you to design a data pipeline for a use case or discuss trade-offs in technology choices. For Staff level, the emphasis is on designing systems that scale, mentoring teams on best practices, and making architectural decisions that balance technical purity with business pragmatism.
Tips & Advice
Prepare by understanding data pipeline architecture patterns, common tools (Apache Airflow for orchestration, Apache Spark for processing, Kafka for streaming, SQL data warehouses like Snowflake or BigQuery), and trade-offs between them. Discuss ETL (Extract-Transform-Load) vs. ELT (Extract-Load-Transform) approaches. Be ready to design a system for a concrete scenario: ingesting order data, customer behavior events, merchant analytics. For Staff level, emphasize your ability to: (1) design systems that scale to high volume and support both batch and real-time use cases, (2) think about data quality, governance, and compliance, (3) mentor teams on architecture trade-offs, (4) balance engineering effort with time-to-value. Discuss challenges like handling late-arriving data, ensuring exactly-once semantics, monitoring data freshness, and schema evolution. Show strategic thinking by discussing when to build custom solutions vs. adopting managed services, and how data infrastructure enables analytics and ML velocity.
Focus Topics
Real-Time Streaming & Event Processing
Understand real-time data systems using tools like Kafka for event streaming and stream processing frameworks. Discuss use cases for real-time analytics (fraud detection, dynamic pricing, real-time dashboards) and challenges (ordering, fault tolerance, exactly-once semantics, state management).
Practice Interview
Study Questions
Scalability, Performance & Cost Optimization
Design systems that handle high data volume, throughput, and low-latency queries. Discuss partitioning strategies, indexing, data compression, and monitoring. Understand trade-offs between latency, throughput, and cost. Optimize for efficient resource utilization and cost-per-query.
Practice Interview
Study Questions
Data Quality, Governance & Compliance
Implement data quality checks: schema validation, completeness checks, uniqueness constraints, and anomaly detection. Establish data governance practices: documentation, ownership, lineage tracking, and access control. Discuss compliance considerations (data privacy, GDPR, PII handling). Design for data reliability and traceability.
Practice Interview
Study Questions
Data Pipeline Architecture & ETL/ELT Patterns
Design end-to-end data pipelines: ingestion from multiple sources (APIs, databases, events), transformation (cleaning, enrichment, aggregation), and consumption (warehousing, dashboards, ML features). Discuss ETL vs. ELT trade-offs, batch vs. real-time processing patterns, and when to use each. Understand orchestration tools like Airflow and how to design for fault tolerance and recovery.
Practice Interview
Study Questions
Onsite Round 5: Behavioral & Leadership
What to Expect
A 60-minute round focused on soft skills, collaboration, leadership, and cultural fit. The interviewer will ask behavioral questions exploring your ability to mentor junior colleagues, influence cross-functional teams, handle conflict, navigate ambiguity, and learn from challenges. Expect questions like 'Tell me about a time you disagreed with a teammate and how you resolved it', 'Describe how you've mentored a junior data scientist', or 'Share an example of a high-impact project where you had to learn a new skill quickly.' For Staff level, the focus is on demonstrated leadership impact, mentorship track record, strategic thinking, and ability to elevate team capability.
Tips & Advice
Prepare 6-8 STAR (Situation, Task, Action, Result) stories that showcase: (1) Driving product decisions through data insights, (2) Mentoring junior data scientists and their career growth, (3) Resolving disagreements or conflicts with teammates, (4) Owning ambiguous problems and bringing structure, (5) Learning a new skill or technology quickly, (6) Navigating organizational constraints to deliver impact, (7) Managing a high-stakes project with tight constraints, (8) Identifying and implementing process improvements. For each story, focus on your agency and impact. Staff-level candidates should emphasize strategic influence, not just individual contributions. Connect stories to DoorDash's values: execution focus, customer obsession, operational excellence, and inclusive culture. Share what you learned from failures and how you adapted. Discuss your leadership philosophy and what you look for in growing talent. Ask thoughtful questions about team dynamics, current challenges, and vision for the data science organization.
Focus Topics
Continuous Learning & Growth Mindset
Discuss how you stay current with data science developments, learn new tools and methodologies, and adapt to changing business needs. Share recent skills you've acquired (new ML frameworks, programming languages, tools). Demonstrate intellectual curiosity and commitment to mastery.
Practice Interview
Study Questions
Ownership & Ambiguity Navigation
Describe an ill-defined problem you tackled, how you brought structure to ambiguity, and how you owned the outcome. Show how you make decisions with incomplete information, validate assumptions, and adapt. Discuss trade-offs you've navigated and why you chose your approach.
Practice Interview
Study Questions
Conflict Resolution & Collaborative Problem-Solving
Describe a time you disagreed with a teammate or stakeholder and how you resolved it. Focus on listening, finding common ground, understanding their perspective, and reaching a resolution that moved the work forward. Avoid defensive language and showcase emotional intelligence and respect.
Practice Interview
Study Questions
Cross-Functional Leadership & Strategic Influence
Demonstrate your ability to lead initiatives across engineering, product, and business teams without direct authority. Share examples of aligning teams on metrics, building consensus on strategy, or influencing prioritization. Discuss your communication style, how you build relationships, and how you handle disagreements. Show strategic thinking in connecting data insights to business decisions.
Practice Interview
Study Questions
Mentorship & Development of Junior Data Scientists
Share specific examples of mentoring junior colleagues: how you helped them develop technical skills, tackle challenging projects, and advance their careers. Discuss your mentorship philosophy, what you look for in mentees, and how you tailor guidance. Show that you've helped others grow into independent, impactful contributors.
Practice Interview
Study Questions
Onsite Round 6: Take-Home Project & Technical Deep Dive
What to Expect
Some DoorDash Staff interviews include a take-home or onsite case study project (1-3 hours) that you'll work on and discuss. You'll be given a realistic data science problem: write SQL queries to answer business questions, conduct exploratory analysis, build a simple model, or investigate a business metric. You'll be expected to deliver clean code, clear reasoning, and actionable insights. This may occur before the onsite as a screening tool or during the onsite day. The follow-up discussion focuses on your approach, problem-solving process, code quality, and ability to articulate findings strategically.
Tips & Advice
Treat the project like real work: clarify requirements, propose an approach, execute with clean code, and communicate findings compellingly. Write well-commented, production-grade SQL and Python/R. For Staff level, go beyond surface-level answers: identify interesting patterns, propose follow-up analyses, and connect findings to business strategy. Consider edge cases and data quality issues. If sharing code, ensure it's clear and maintainable. In the discussion, be prepared to defend your methodology, discuss alternative approaches, and answer follow-up questions. Walk through your analytical process, explaining key decisions. Highlight strategic insights and business implications, not just numbers. Show that you think about how findings would be operationalized or drive decisions.
Focus Topics
Clear Communication & Data Storytelling
Present findings clearly with supporting evidence and visualizations. Articulate the business implication of each insight. Synthesize findings into a compelling narrative. Be prepared to defend your analytical approach and discuss alternatives. Tailor communication to the audience.
Practice Interview
Study Questions
Code Quality & Best Practices
Write SQL and code that is clear, efficient, and maintainable. Use meaningful names, clear structure, helpful comments, and proper formatting. Optimize for performance without sacrificing readability. Demonstrate knowledge of best practices. Code should be something you're proud to show others.
Practice Interview
Study Questions
Strategic Insight Generation & Business Impact Thinking
Move beyond answering the specific question to identifying interesting patterns, proposing follow-up analyses that would deepen understanding, and connecting findings to business strategy. Show curiosity and depth. Discuss how insights would inform decisions or drive action.
Practice Interview
Study Questions
End-to-End Analytical Execution & Problem-Solving
Execute a complete analysis from problem statement to insights: clarify ambiguous requirements, propose analytical approach, write efficient SQL, perform exploratory analysis, identify patterns, validate findings, and present conclusions. Demonstrate logical thinking, attention to detail, and structured problem decomposition. Discuss assumptions and caveats explicitly.
Practice Interview
Study Questions
Frequently Asked Data Scientist Interview Questions
Compute the median (50th percentile) of a numeric column using PERCENTILE_CONT, or a manual NTILE/ROW_NUMBER-based workaround in a dialect that lacks it. Then discuss when you'd switch to an approximate method (sketch-based quantile estimation, or an engine's built-in approximate-quantile function) instead of the exact windowed computation, and how you'd communicate that trade-off to a stakeholder who just wants 'the median'. Extend the same exact-versus-approximate framing to a related problem: an exact running-distinct-count of active users by day gets expensive at scale, and HyperLogLog-style sketches are the usual approximate alternative.
Sample Answer
Direct answer: PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY col) is the exact, standard way to compute a median in engines that support ordered-set aggregates (Postgres, Snowflake, BigQuery, DuckDB): it sorts the group and interpolates between the two middle values. Engines without it (MySQL, SQLite, older warehouses) need a manual ROW_NUMBER() workaround that ranks each group and averages the middle row (even count) or takes the single middle row (odd count). Switch to an approximate, sketch-based quantile function once the exact sort-per-group computation becomes the bottleneck at scale, and tell the stakeholder plainly: "this number is very close but not exact, and it will stay fast as the data grows."
Structured elaboration
Approach 1: exact, ordered-set aggregate
PERCENTILE_CONT is an ordered-set aggregate function, not a plain window function. It always needs WITHIN GROUP (ORDER BY ...) and a GROUP BY (or no GROUP BY at all for one global median). PostgreSQL's documentation is explicit that ordered-set aggregates cannot be used as window functions with OVER (...); DuckDB rejects the same syntax outright. On PostgreSQL and DuckDB specifically, if you need a per-partition median attached to every row (window-style), you compute the aggregate in a subquery or CTE (common table expression, a named, reusable subquery introduced with WITH) and join it back, since neither engine lets you bolt OVER (PARTITION BY ...) directly onto PERCENTILE_CONT. That restriction is not universal: Snowflake and Redshift both document PERCENTILE_CONT(...) WITHIN GROUP (ORDER BY ...) OVER (PARTITION BY ...) as valid windowed syntax, so on those two engines the per-partition median can be a single expression with no join-back step.
Approach 2: manual ROW_NUMBER() workaround (portable, works anywhere)
Rank each row within its group by the target column, count the group size, and average the row(s) sitting at the middle rank(s):
WITH numbered AS (
SELECT
category_id,
amount,
ROW_NUMBER() OVER (PARTITION BY category_id ORDER BY amount) AS rn,
COUNT(amount) OVER (PARTITION BY category_id) AS cnt
FROM transactions
WHERE amount IS NOT NULL
)
SELECT category_id, AVG(amount) AS median_amount
FROM numbered
WHERE rn IN (FLOOR((cnt + 1) / 2.0), CEILING((cnt + 1) / 2.0))
GROUP BY category_id;
For an odd group size the two FLOOR/CEILING picks land on the same rank, so AVG of one value is just that value; for an even group size they land on the two middle ranks and AVG interpolates the way PERCENTILE_CONT does. NTILE(2) is sometimes mentioned in the same breath as this workaround, but it is a coarser tool: it splits a group into equal-sized buckets and tells you which bucket a row falls in, it does not interpolate a boundary value, so it is the right primitive for quartile/decile bucketing, not a precise substitute for a point-estimate median.
Approach 3: approximate, sketch-based quantile estimation
Once a partition is large enough that sorting it (the O(n log n) step both approaches above rely on) means spilling to disk or holding the whole group in memory, switch to a probabilistic sketch such as t-digest, a compact, mergeable summary structure that approximates quantiles instead of computing them exactly. These structures process the data in one streaming pass, keep a small, bounded amount of state regardless of how many rows feed into it, and answer a quantile query with a small, known error bound instead of an exact sort. Every major analytical warehouse ships a built-in function for this: DuckDB's APPROX_QUANTILE, Snowflake's APPROX_PERCENTILE (built on a t-digest variant), BigQuery's APPROX_QUANTILES (returns an array of boundary values), and Redshift's APPROXIMATE PERCENTILE_DISC.
When to switch, and how to say it to a stakeholder
Switch when the exact computation is measurably the bottleneck: a group so large that the sort spills to disk, a high-cardinality GROUP BY key producing thousands of small sorts, or a dashboard that needs to stay responsive as the underlying table grows unbounded. Do not switch pre-emptively on a small or medium table just because "approximate" sounds more scalable; exactness is free until it isn't. When a stakeholder asks for "the median" and you plan to serve an approximate one, say what changes in plain terms: the number will be extremely close to the true median (typically within a fraction of a percent for standard sketch sizes) and it will stay fast no matter how much data accumulates, versus an exact number that is guaranteed correct but gets slower, and eventually a background batch job, as volume grows. If the number feeds a regulated or audited report, keep it exact; if it feeds a live operational dashboard, approximate is almost always the right trade.
Extension: exact-vs-approximate distinct counts
The same tension shows up one level over, on COUNT(DISTINCT user_id) for a daily active-users metric. An exact distinct count forces the engine to track every value it has already seen (a hash set or a sort-and-dedupe pass), so memory and compute scale with the number of distinct values, not just the row count, and a single query with several COUNT(DISTINCT ...) metrics can be especially expensive because each one needs its own tracking structure. HyperLogLog-style sketches solve it the same way t-digest solves quantiles: hash each value, keep a small fixed-size register array (kilobytes, not megabytes, regardless of whether the true distinct count is a thousand or a billion), and estimate the cardinality from the distribution of leading zero-bits observed. The error shrinks as the sketch's register count grows, and standard sizes comfortably keep the relative error to a low single-digit percentage, which is normally far tighter than a stakeholder needs for a trend line. DuckDB exposes this as APPROX_COUNT_DISTINCT; BigQuery, Snowflake, and Redshift ship equivalents (BigQuery additionally exposes the raw HLL_COUNT.* sketch functions so you can store and merge partial sketches across days instead of recomputing from scratch).
Worked example
Ran against a real transactions(category_id, amount) table in DuckDB, category_id = '1' has an odd count of five rows (10, 20, 30, 40, 100), category_id = '2' has an even count of four rows (5, 15, 25, 35):
-- Approach 1: exact, ordered-set aggregate
SELECT category_id, PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY amount) AS median_amount
FROM transactions GROUP BY category_id;
| category_id | median_amount |
|---|---|
| 1 | 30 |
| 2 | 20 |
Category 1's median is the literal middle value (30). Category 2 has no single middle value, so PERCENTILE_CONT interpolates between the two middle values 15 and 25, giving (15+25)/2 = 20. The manual ROW_NUMBER() query from Approach 2, run against the same table, returned identical results (30 and 20), confirming the two exact methods agree. APPROX_QUANTILE(amount, 0.5) also returned 30 and 20 on this table, because the demo dataset is far too small for a sketch's approximation error to show up. The whole point of switching to a sketch only pays off at the row counts where an exact sort would actually hurt, which a nine-row demo table cannot honestly simulate; the sketch's real behavior is a bounded-error, bounded-memory summary, not a different answer on small data.
For the distinct-count extension, an active_users(event_date, user_id) table with 3 distinct users on day one and 4 distinct users on day two returned identical results from COUNT(DISTINCT user_id) and APPROX_COUNT_DISTINCT(user_id) for the same reason: at single-digit cardinality there is nothing for a sketch to approximate away.
Key points
PERCENTILE_CONTis an ordered-set aggregate: exact, needsWITHIN GROUPandGROUP BY, and (verified against PostgreSQL's own documentation and by direct execution) cannot take anOVER (PARTITION BY ...)clause the way a true window function can.PERCENTILE_CONTsilently dropsNULLvalues from the ordering before computing the median (verified: a group of 10, 20, NULL, 30 returned a median of 20, the same as if theNULLwere never there).NTILEbuckets rows into N groups; it is a bucketing tool, not an interpolating median calculator.
Complexity
Both exact approaches require a full sort of each group: O(n log n) per group, and the whole group must be materialized before the middle value(s) can be identified, so memory scales with the largest group's size. Sketch-based approximate methods process each row once, O(n) total, using a fixed, small amount of memory per sketch regardless of group size, which is exactly what makes them viable when the exact sort would spill to disk.
Edge cases
- Empty group: both
PERCENTILE_CONTand theROW_NUMBER()approach returnNULL(no rows to rank). NULLvalues in the target column: excluded from the ordering before the median is computed; make surecntin the manual approach is aNULL-excluding count (COUNT(amount), notCOUNT(*)) or the rank-matching math drifts.- Ties at the middle rank(s) are handled correctly by both exact approaches since they operate on sorted position, not on distinct values.
Trade-offs & pitfalls
The trap most candidates miss is reaching for NTILE as if it were a median shortcut; it answers a different question (which bucket) and does not interpolate. The trap on the approximate side is presenting a sketch-based number as if it were exact without saying so: a dashboard KPI silently switching from exact to approximate after a "performance fix" is the kind of change that erodes stakeholder trust in the numbers, even when the approximation itself is well within an acceptable error band. State the switch and its error characteristics explicitly rather than letting it hide inside a query rewrite.
What's your framework for deciding when a stalled cross-team dependency needs to go to leadership versus continuing to work it peer-to-peer?
Sample Answer
Direct answer
Keep a stalled dependency peer-to-peer as long as direct conversation is still making progress. Escalate when you hit a concrete trigger: a scope change that neither side can unilaterally absorb, genuinely conflicting priorities that only someone with visibility into both roadmaps can arbitrate, or a hard deadline-driven blocker where peer-to-peer conversation has already stalled.
Framework
Default: work it peer-to-peer. Most stalls are under-communication or unclear ownership, and a direct conversation or a short written proposal usually unsticks them without anyone else getting involved.
Concrete triggers to escalate.
- Scope change: the fix now requires work neither team budgeted for, and only a manager can reprioritize that.
- Conflicting priorities: both sides are acting rationally from their own team's goals, and the trade-off needs someone with visibility into both roadmaps to arbitrate.
- Hard blocker with a deadline: a fixed external date is genuinely at risk, and peer-to-peer conversation has already stalled past a reasonable window, for example no movement after two direct attempts over several days.
- Repeated pattern: the same kind of stall keeps recurring with the same team, which means the real issue is the working relationship or process, not this one dependency.
What to bring when you escalate. A short brief: what's blocked, what you've already tried peer-to-peer, the realistic options and their trade-offs, and the specific decision you need.
Worked example (applying the criteria)
Situation: your team's deliverable needs a schema change from another team that they've deprioritized for two weeks despite two direct requests.
Applying the criteria: this isn't just a communication gap, direct conversation was already tried twice with no movement. It's a conflicting-priorities case, the other team's roadmap has no room for this without reprioritizing something else, combined with a hard blocker, a fixed external deadline in three weeks that this schema change sits on the critical path for (meaning if this dependency slips, the final deadline slips by the same amount, unlike a dependency with buffer to absorb delay).
Action: escalated to the shared manager with a one-page brief covering what's blocked, the two peer-to-peer attempts and their outcome, and two options: the other team reprioritizes one sprint of work, or your team ships a temporary workaround with known limitations, along with the deadline risk if neither happens within the week.
Result: the shared manager reprioritized one sprint item, unblocking the schema change with two weeks to spare before the deadline. Both teams also agreed to flag scope-affecting asks earlier next time, so the same dependency doesn't reach this point again.
Trade-offs and pitfalls
- Escalating too early over normal friction burns trust and reads as an inability to work horizontally.
- Escalating too late, repeatedly trying peer-to-peer past the point it's actually working, puts the deadline at real risk and looks like poor judgment in hindsight.
- A vague escalation with no options and no specific ask wastes the leader's time compared with a brief that names the decision needed.
Explain the difference between event-based analytics and pageview- or session-based analytics. Describe the data model each implies, one advantage and one disadvantage of each, and give an example of a user-behavior question that is best answered by each approach.
Sample Answer
Direct answer
Event-based analytics models the world as a stream of discrete, named actions a user takes (clicked, purchased, viewed), each carrying its own properties, while pageview- or session-based analytics models the world as page loads grouped into sessions, with actions inferred indirectly from which pages were loaded and in what order. The two imply genuinely different data models, not just different tooling.
Structured elaboration
In an event-based model, the atomic unit is the action itself: a "purchase" event fires with properties like amount and item, independent of any specific page. This makes it straightforward to answer questions about specific in-product actions, including actions that happen without a page reload, such as an in-app interaction inside a single-page application or a native mobile screen. The disadvantage is that it requires deliberate, ongoing engineering investment: every action worth analyzing has to be explicitly instrumented, named, and given a stable schema, and gaps in that instrumentation become gaps in what can be analyzed.
In a pageview-based model, the atomic unit is the page load, and sessions are built up from a sequence of page loads within an inactivity window. This is cheap to get broad coverage from, since a basic page-load tag on every page captures something without any per-action engineering work, but it is much weaker at answering questions about what a user actually DID on a given page, since a page load says nothing about what was clicked, filled in, or ignored within it.
A user-behavior question best answered by the event-based approach is something like "what fraction of users who opened the settings panel actually changed their notification preference," since that is an in-page action with no corresponding page load. A question best answered by the pageview-based approach is something like "what is the typical navigation path visitors take through the site before leaving," since that is fundamentally about sequences of pages rather than in-page actions.
Worked example
Consider a single-page checkout flow with three visible screens (cart, shipping, payment) that never triggers a full page reload, plus a "save for later" action available from the cart screen. A pageview-based analytics setup, tagging only on page load, would see exactly one page load for the entire flow and would have no way to tell whether "save for later" was ever clicked, since that action does not correspond to a new page. An event-based setup instrumenting cart_viewed, save_for_later_clicked, shipping_step_viewed, and payment_step_viewed as distinct events would correctly capture that a user reached the cart, clicked save-for-later, and never advanced further, giving a materially different and more accurate picture of where the drop-off actually happened than the pageview-only view, which would simply record one page visit with no further detail.
Trade-offs and pitfalls
A common mistake is assuming an event-based system automatically supersedes a pageview-based one; in practice, many products run both, using pageviews for cheap, broad top-of-funnel visibility and events for the specific in-product actions the team most needs to understand. The pitfall to watch for is treating a page-load count as a proxy for engagement inside modern single-page applications, where a single page load can hide an arbitrary amount of real user activity that never shows up without explicit event instrumentation.
Tell me about a time you diagnosed and fixed a real production database performance problem. Using the STAR format, describe how you noticed and measured it, what you changed, and the concrete impact once it shipped.
Sample Answer
Direct answer. A dashboard that had quietly grown from a few hundred thousand rows to several million was taking eight to twelve seconds to load; I traced it to a sequential scan feeding a nested loop join whose row-count estimate was badly stale, fixed it with a statistics refresh plus a targeted composite index, and got it back under a second.
Structured elaboration. Situation: an internal reporting dashboard, previously fast, had degraded gradually enough that no single deploy looked like the cause, and initial suspicion fell on the application layer rather than the database. Task: find the actual bottleneck and fix it without a major schema change, since the dashboard needed to stay available. Action: I ran EXPLAIN ANALYZE against the slow query directly (rather than trusting application-level timing alone) and found the estimated row count for the main filter was off by roughly two orders of magnitude from the actual, which had pushed the optimizer toward a nested loop join that made sense for the old, smaller estimate but was disastrous for the real, current volume; I confirmed a stale-statistics diagnosis by checking when statistics had last been refreshed on the affected table (a while before the data had grown), refreshed them, and added a composite index that matched the query's actual filter-plus-sort pattern, which the old, smaller table hadn't needed.
Result: dashboard load time dropped from the eight-to-twelve-second range to under one second, confirmed by re-running EXPLAIN ANALYZE and seeing the plan switch to an index scan with estimated and actual row counts now closely matched, plus a follow-up check a week later confirming the improvement held under real traffic rather than being a one-off measurement.
Trade-offs and pitfalls. The fix itself was straightforward once correctly diagnosed; the harder part was resisting the urge to guess at an application-layer cause first, since the symptom (a "slow page") didn't obviously point at the database until I actually looked at a real execution plan rather than just a wall-clock timing number.
Implement in Python a custom scikit-learn transformer class GroupMedianImputer that imputes missing numeric values by the median for a specified group column. Your class should implement fit/transform/get_params and support scikit-learn Pipelines. Include unit tests that demonstrate behavior for unseen groups during transform and for groups with all-null values.
Sample Answer
To impute numeric values by group median in a scikit-learn-compatible transformer, compute medians per group during fit, store a global median as fallback, and during transform map group->median, using global for unseen groups or groups with all-null. Here's a robust implementation and unit tests.
import pandas as pd
import numpy as np
from sklearn.base import BaseEstimator, TransformerMixin
class GroupMedianImputer(BaseEstimator, TransformerMixin):
"""
Impute numeric column(s) by group median from a group column.
Parameters:
- group_col: name of column to group by
- value_cols: single column name or list of numeric columns to impute
- fill_value: optional constant fallback (if None, use global median)
"""
def __init__(self, group_col, value_cols, fill_value=None):
self.group_col = group_col
self.value_cols = value_cols if isinstance(value_cols, (list, tuple)) else [value_cols]
self.fill_value = fill_value
def fit(self, X, y=None):
X = pd.DataFrame(X).copy()
# compute group medians for each value_col
self.group_medians_ = X.groupby(self.group_col)[self.value_cols].median()
# global medians for fallback
self.global_medians_ = X[self.value_cols].median()
# if user specified constant fill_value, keep it
return self
def transform(self, X):
X = pd.DataFrame(X).copy()
# map each value_col using group medians; unseen groups -> NaN then replace
def impute_col(col):
mapped = X[self.group_col].map(self.group_medians_.get(col, pd.Series()))
# pandas .map with Series uses index alignment; ensure fallback
mapped = X[self.group_col].map(self.group_medians_.get(col, pd.Series(index=self.group_medians_.index, data=self.group_medians_[col])))
result = X[col].where(X[col].notna(), mapped)
# fallback: if still NaN (unseen group or group's median NaN), use fill_value or global median
fallback = self.fill_value if self.fill_value is not None else self.global_medians_[col]
result = result.fillna(fallback)
return result
for col in self.value_cols:
X[col] = impute_col(col)
return X
def get_params(self, deep=True):
return {"group_col": self.group_col, "value_cols": self.value_cols, "fill_value": self.fill_value}
Unit tests (pytest):
def test_group_imputer_basic():
df = pd.DataFrame({
"group": ["a","a","b","b","c"],
"x": [1.0, np.nan, 3.0, np.nan, np.nan]
})
imp = GroupMedianImputer("group", "x")
imp.fit(df)
out = imp.transform(df)
# group a median = 1.0 -> fills a's NaN; group b median = 3.0 -> fills b's NaN
assert out.loc[1, "x"] == 1.0
assert out.loc[3, "x"] == 3.0
def test_unseen_group_and_all_null_group():
train = pd.DataFrame({
"group": ["a","a","b"],
"x": [10.0, np.nan, np.nan] # group b has all-null -> group's median NaN
})
test = pd.DataFrame({
"group": ["a","b","c"],
"x": [np.nan, np.nan, np.nan] # c is unseen
})
imp = GroupMedianImputer("group", "x")
imp.fit(train)
out = imp.transform(test)
# global median computed from train is 10.0
assert out.loc[0, "x"] == 10.0 # a's median
assert out.loc[1, "x"] == 10.0 # b had all-null -> fallback to global median
assert out.loc[2, "x"] == 10.0 # unseen group -> fallback to global median
Key points:
- Compatible with sklearn Pipelines (implements fit/transform/get_params).
- Handles unseen groups and groups with all-null by falling back to global median or user-provided fill_value.
- Time: O(n) to compute medians and O(n) to transform; Space: O(g + n) where g is number of groups.
What does the write-audit-publish pattern mean for a pipeline's data quality, and what problem does inserting an audit step before publish actually solve?
Sample Answer
Direct answer
Write-audit-publish means landing new data in a staging location consumers can't see yet, running data-quality checks (the audit) against it while it is still invisible, and only then making it visible with a single atomic operation (a partition swap or a pointer flip), rather than publishing first and validating afterward. The audit step exists to solve the problem of consumers reading bad or partial data during a load: without it, "load then check" means anyone querying during or right after a bad load already saw the wrong numbers before any check had a chance to catch it.
Structured elaboration
The problem this solves. A pipeline that writes directly into the table or partition consumers actually query, then validates afterward if at all, leaves a window between when writes start and when a check would have failed, during which consumers can read incomplete or wrong data with no visible signal anything is wrong.
The three stages:
- Write. Land the new batch in an isolated location, a staging table, a new partition or version, a new file set, that existing queries against the published location cannot see at all.
- Audit. Run validation against that staged data while it remains invisible to consumers: row counts against expectation, null rates, schema conformance, referential checks, business-rule checks.
- Publish. Only if the audit passes, flip visibility with a single atomic operation, an atomic partition swap, a metadata pointer update, or a table rename, so consumers see either the previous, already-audited state or the new, now-audited state, never a partial mix of the two.
Why the publish step has to be atomic. If publishing itself were multiple steps (remove old rows, then insert new ones), a reader querying in the middle could see an inconsistent partial state even after the audit already passed. The pattern only fully solves the visibility problem if the very last step is a single, indivisible flip.
What happens when the audit fails. The staged batch is simply never published. Production keeps serving the last good, already-audited state, and the failed batch goes to remediation instead of ever becoming visible to anyone.
Where it fits and where it doesn't. This suits batch or micro-batch loads into a location with many downstream readers who can't each validate before consuming, like a shared warehouse table. Strict low-latency streaming, where staging and swapping an entire batch isn't practical, achieves the same underlying goal (don't let one bad unit block or corrupt everyone) through per-record dead-letter handling instead.
Worked example
A daily table normally holds 2,000,000 rows. A join bug in that day's load causes fanout, and the staged batch lands with 2,600,000 rows:
2,000,0002,600,000−2,000,000=30% overcountIf the audit's row-count check allows a tolerance band of plus-or-minus 5 percent around the historical baseline, a 30 percent deviation fails it clearly, so the atomic swap never happens. Consumers keep reading yesterday's correct 2,000,000-row table while the bad batch sits quarantined and the join bug gets fixed, instead of every downstream report briefly, or permanently until someone happens to notice, reflecting a 30 percent inflated count.
flowchart LR
A[New batch written to staging] --> B[Audit checks run on staged data]
B -->|pass| C[Atomic publish: swap or pointer flip]
B -->|fail| D[Staged data quarantined]
C --> E[Consumers read new data]
D --> F[Remediation and retry]
F --> A
Trade-offs & pitfalls
- Auditing the already-published table instead of the staged one only catches the problem after consumers may already have read bad data; the ordering, audit before publish rather than after, is the entire point of the pattern.
- Making publish itself a multi-statement operation reintroduces the exact partial-visibility problem the pattern exists to prevent.
- The pattern trades some latency (data isn't visible until the audit finishes) and some storage (staged and published copies briefly coexist) for that safety; that's a clear win for a widely-consumed shared table, and a less obvious win for a low-stakes, single-consumer dataset where the extra latency may not be worth it.
- A common wrong turn is treating "we run some validation somewhere in the pipeline" as equivalent to write-audit-publish; the pattern specifically depends on the audited data being invisible to consumers until it passes, not just checked at some point along the way.
You ran an A/A test and observed a 7% difference in conversion between the two identical groups with p=0.04. List the possible explanations for this surprising result, such as a broken hashing or salt scheme, covariate imbalance from a logging bug, or a genuinely low-probability chance event, and outline the concrete diagnostics you would run, in order, to determine which explanation is correct and what you would do next.
Sample Answer
Direct answer
A 7% conversion gap between two arms of an A/A test with p = 0.04 is surprising but not automatically evidence of a broken pipeline: with a conventional alpha, roughly 1 in 20 A/A tests will cross p < 0.05 by chance alone even with perfect randomization, so a single significant A/A result sits right at the boundary between noise and something worth investigating. The right response is a fixed sequence of diagnostics, cheapest and most mechanical first, that can positively confirm or rule out each concrete failure mode: broken hashing or salting in the assignment logic, a covariate imbalance introduced by a logging bug, or ordinary sampling variation.
Structured elaboration
Ordered diagnostics
- Reproduce on raw logs with a fixed seed. Re-run the exact analysis against raw exposure and outcome events, not a downstream aggregated table, to rule out an analysis or pipeline bug before suspecting randomization itself.
- Check the allocation ratio. Confirm the number of users landing in each arm matches the intended split; a large deviation from the intended ratio is one of the strongest and cheapest signals that the hashing or salting scheme is broken, and it is a distinct check from the 7% conversion gap itself. An experiment can have a balanced allocation and still show a spurious metric difference, or a skewed allocation and a metric difference that is actually the real symptom.
- Audit covariate balance, not just the topline metric. Compare the two arms on pre-experiment covariates that should be identical under correct randomization: browser type, geography, device, and signup cohort. If, for example, one arm has a meaningfully different browser or region mix, that points directly at the hashing or salting scheme, perhaps it is keyed on something correlated with browser or region rather than a clean user id, rather than at chance.
- Audit instrumentation and logging for the affected population, not just in aggregate. Check whether the difference is spread evenly across all users or concentrated in a specific segment, for example a subset of power users whose events are logged differently or who hit a code path that assigns or tags them incorrectly; a difference concentrated in one segment is far more consistent with a logging bug than with chance, since chance-driven noise does not usually cluster by user type.
- Check for multiple looks and multiple metrics. Confirm this is the primary metric and the first pre-registered look at the data; if the gap emerged after peeking at several days or several metrics, the effective false-positive rate is higher than the nominal 5% used to compute that p = 0.04.
- Re-run on an independent window if steps 1 to 5 find nothing. If every mechanical check comes back clean, run a fresh A/A on a new time window, not the same data re-sliced, before concluding the original result was real noise; a second clean A/A is much stronger evidence than reasoning about a single result in isolation.
Practical thresholds for concern
A single A/A test crossing the standard p < 0.05 threshold is expected roughly 1 in 20 times under correct randomization and is not, by itself, cause for alarm. Because allocation-ratio checks tend to run on every experiment in a mature program, many teams apply a stricter threshold specifically to that check, for example requiring p < 0.001 before treating a deviation as a real problem, because running a 0.05-threshold check on every one of hundreds of experiments would itself generate frequent false alarms. This is a practitioner convention for managing check-your-own-checks noise, not a statistical property being claimed as derived; teams calibrate the exact cutoff to their own experiment volume.
Worked example
Take the power-user logging-bug scenario concretely, with stated illustrative inputs. Suppose the population is 1,000,000 users, correctly randomized 50/50 by the underlying hashing scheme. Power users are 10% of the population (100,000 users), and a logging bug causes every power user's exposure event to be recorded under the control label regardless of which arm they were actually assigned to.
Non-power users (900,000) log correctly: 450,000 recorded as control, 450,000 recorded as treatment. Power users (100,000) all log as control regardless of true assignment.
Recorded control=450,000+100,000=550,000,Recorded treatment=450,000
Recorded split=55%:45%
A 55/45 recorded split against an intended 50/50 is a large, easily detectable sample-ratio deviation, exactly the kind of signal step 2 is designed to catch, and it would also explain a spurious conversion difference: if power users convert at a different rate than the general population, mislabeling all of them into "control" pulls the control arm's average toward the power-user rate and creates a gap that has nothing to do with the treatment itself.
Trade-offs and pitfalls
- Investigating every marginal A/A result exhaustively is expensive; teams running many experiments generally accept a small, known false-alarm rate rather than deeply diagnosing every borderline case, but should still run the cheap mechanical checks (steps 1 to 3) before shipping a launch decision built on top of infrastructure that produced a suspicious A/A.
- A clean allocation ratio does not prove randomization is unbiased end to end; a hashing scheme can produce a correct overall 50/50 split while still being correlated with a covariate, for example alternating by the last digit of a sequential user id, which can correlate with signup cohort. The ratio check and the covariate-balance check are complementary, not substitutes for each other.
- Re-running on a new window is the strongest single diagnostic but takes real calendar time, so it should be the last check, not the first, when cheaper log-based checks can often localize the problem faster.
- Concluding "just noise" without running the mechanical checks at all is itself a pitfall: an unresolved instrumentation bug found only after it has already contaminated a live experiment is far more costly than the time it takes to check allocation ratio and covariate balance up front.
Walk me through a situation where you had to tailor your pitch to a specific stakeholder's priorities and incentives, rather than repeating your own rationale, in order to win them over.
Sample Answer
Direct answer
Tailoring a pitch means finding out what that specific stakeholder is actually measured on or afraid of, and reframing the same underlying facts through that lens, rather than repeating your own rationale and hoping it lands. The facts stay fixed; only the framing and the risk language change per audience.
Structured elaboration
Incentive-mapping framework. Before drafting anything, identify what the stakeholder optimizes for and what they fear, then reframe the same evidence in that currency:
| Audience | Optimizes for | Fears | The reframe |
|---|---|---|---|
| Engineering leadership | Delivery velocity, system reliability | Rising technical debt, on-call burden | Frame as throughput and operational load |
| Finance | Predictable, defensible spend | Uncontrolled or one-time crisis cost | Frame as cost trajectory and budget certainty |
| Revenue or go-to-market leadership | Time-to-market, customer impact | Losing deals or churn | Frame as customer-facing risk or opportunity |
| Security or compliance leadership | Risk exposure, audit posture | An incident or failed audit finding | Frame as exposure window and control mapping |
A common variant of this: translating a technical or security risk into business-impact terms to win executive buy-in. The reframe isn't inventing a new argument; it's restating the same risk in the currency the executive is accountable for (revenue at risk, compliance exposure, customer churn) instead of engineering terms (a vulnerability class, a latency percentile).
Worked example
Situation. At a platform company, engineering wanted budget approval to fix an authentication vulnerability class a penetration test had flagged. The CFO's first read was that this belonged in the engineering backlog, not an urgent ask.
Stakes. The unpatched vulnerability class carried real breach and compliance exposure, but it was competing for the same budget cycle as revenue-generating projects, and the CFO wasn't going to fund it on engineering language alone.
The influence moves.
- Learned the CFO's actual incentive: quarterly budget defensibility and avoiding one-time crisis spend, not an abstract security posture.
- Reframed the same evidence in the CFO's terms: translated "session tokens that don't expire" into an exposure-window estimate and a cost comparison against the company's own past incident-response spend, the same kind of trade-off the CFO already used elsewhere.
- Built a separate, differently framed one-pager for the security lead from the same underlying evidence: audit and control-mapping language, naming which control had failed and which policy clause it mapped to, instead of repeating the CFO pitch.
- Verified the incentive rather than assuming it, by asking the CFO's chief of staff beforehand what kind of comparison the CFO typically used to evaluate risk spend.
Resolution. The CFO approved the fix as a scheduled, budgeted project rather than an emergency spend, because the exposure was quantified and mapped to a comparison already familiar from other risk trade-offs.
What a senior candidate does differently. A mid-level candidate builds one deck and hopes it lands for everyone. A senior candidate keeps the underlying evidence fixed and swaps only the framing and incentive language per audience, and can explain, in the room, why that phrasing fits that specific person.
Trade-offs and pitfalls
- Tailoring is not spin. The underlying facts must be identical across audiences. If the CFO version and the CISO version (CISO: Chief Information Security Officer, the same person referred to earlier in this example as "the security lead") would lead a skeptical listener to different conclusions about severity, that's manipulation, not tailoring.
- Guessing the wrong incentive misses as badly as not tailoring at all. Verify the incentive with a quick question rather than assuming it from a title.
- Prep cost. Building a separately framed pitch per audience takes real time; reserve heavy tailoring for stakeholders whose buy-in is genuinely load-bearing for the decision.
Your training pipeline spends more time reading and preprocessing examples than updating weights. Data arrives in many small files from object storage, and every epoch redoes expensive transformations. How would you redesign the input path so the GPUs stay busy while preserving reproducibility and debuggability?
Sample Answer
Redesign the input path
I would separate expensive preprocessing from the training loop and make the input stream sharded, cached, and deterministic.
Main changes
- Compact many small object-store files into larger shards so reads are sequential instead of chatty.
- Precompute expensive transforms once, then store the transformed output or an intermediate cache.
- Use a manifest that records shard order, sample IDs, and versioned transform code.
- Prefetch data to local disk or memory so GPUs do not wait on network reads.
- Keep lightweight, deterministic transforms in the training worker so results are reproducible.
Worked example
If the dataset is 10,000 files of 2 MB each, that is 20 GB spread across many requests. Repacking into 200 shards of 100 MB keeps the same 20 GB, but cuts file open and listing overhead dramatically.
Why this helps
The GPUs stay busy because decoding and network latency happen ahead of time. Reproducibility comes from versioned manifests and fixed seeds. Debuggability comes from keeping raw sample IDs so a bad example can be replayed exactly.
This is usually the highest leverage change when preprocessing time dominates training time.
A PM asks to "make the model faster" but offers no details about latency targets or bottlenecks. Outline a profiling and optimization plan: how you'd measure current performance, identify bottlenecks (CPU, I/O, serialization), what optimizations you might apply (model compression, batching), and how you'd evaluate trade-offs.
Sample Answer
Plan: treat this as an empirical profiling → targeted optimization → validation cycle.
- Baseline measurement
- Define metrics: P50/P95/P99 latency, throughput (reqs/s), cold vs warm start, CPU/GPU utilization, memory, network I/O, serialization time, tail latency spikes.
- Collect real-world traces and synthetic load (locust/hey/k6). Log timestamps at ingress, pre-model, post-model, and egress to attribute stages.
- Identify bottlenecks
- Micro-profiling: use Python profilers (cProfile, py-spy), torch.profiler/torch.autograd.profiler, TensorFlow Profiler, NVIDIA Nsight, perf, or eBPF tracing for system-level.
- Measure serialization/parsing with timers around JSON/protobuf steps; measure network RTT and throughput.
- CPU vs GPU: check utilization and CUDA kernels time. Disk/I/O: use iostat, strace for file ops.
- Visualize with flame graphs, timeline traces, and waterfall charts to pinpoint hotspots.
- Optimization candidates (with rationale)
- Model-level: quantization (INT8), pruning, distillation — reduces compute and memory but may slightly reduce accuracy.
- Compilation: TorchScript/ONNX + TensorRT/TVM for operator fusion and faster kernels.
- Serving-level: batching requests (dynamic/static batching) to increase throughput; asynchronous worker pools; increase concurrency carefully to avoid queueing latency.
- Input pipeline: cache/validate/preprocess offline; use binary serialization (protobuf/flatbuffers) to reduce parse time.
- System: move from CPU to GPU or to inference accelerators, use larger instance types or autoscaling; enable pinned memory and zero-copy where possible.
- Architectural: model sharding, warm pools, avoid cold starts, cache frequent predictions.
- Evaluate trade-offs & experiments
- For each change run controlled experiments: measure latency percentiles, accuracy on validation set, cost per inference, memory footprint, and failure modes.
- Use canary/A-B rollout: compare business metrics and monitor regressions.
- Document acceptable accuracy-latency-cost frontier and propose options (e.g., INT8 for 2x speedup with <0.5% accuracy loss).
- Rollback plan and observability: dashboards (Grafana), alerts on tail latency and accuracy drift.
- Deliverables & timeline
- Day 1–3: baseline + hot spots report
- Day 4–10: implement 1–2 low-risk wins (batching, serialization), measure
- Week 2–4: heavier changes (quantize/compile) + canary rollout
- Final: recommendation with numeric trade-offs and runbook.
This approach gives measurable improvements while quantifying accuracy and cost trade-offs.
Recommended Additional Resources
- DoorDash Engineering Blog: Articles on machine learning, data infrastructure, and experimental design practices
- DataLemur: DoorDash SQL interview questions and practice problems with detailed solutions
- Interview Query: DoorDash data scientist interview guide with case studies and real question examples
- StrataScratch: Real DoorDash SQL interview questions from actual candidates with community solutions
- Prepfully: Comprehensive DoorDash data scientist preparation with interview walkthroughs
- Books: 'Designing Data-Intensive Applications' by Martin Kleppmann, 'The Art of Statistics' by David Spiegelhalter, 'Lean Analytics' by Alistair Croll and Benjamin Yoskovitz, 'Storytelling with Data' by Cole Nussbaumer Knaflic
- Online Learning: StatQuest with Josh Starmer on YouTube (statistics and ML fundamentals), Andrew Ng's Machine Learning Specialization on Coursera, Stanford CS109 Data Science course materials
- Experimentation: 'Trustworthy Online Controlled Experiments: A Practical Guide to A/B Testing' by Kohavi, Tang, and Xu
- Community Resources: Blind (interview experiences from DoorDash candidates), Levels.fyi (salary and interview data), LinkedIn (DoorDash employee profiles and recent initiatives)
Search Results
Ace the DoorDash Data Scientist interview: Proven 2025 guide
Interview Questions · How do you analyze if a product is successful? · What are the most important metrics for DoorDash? · How do you measure revenue and cost?
DoorDash Data Scientist Interview in 2025 (Leaked Questions)
Can you describe a project where you used data to influence a decision? · How do you approach solving ambiguous problems? · What analytics tools ...
DoorDash Data Scientist Interview Guide: Questions, Case Studies ...
Expect questions on how you've influenced product decisions, aligned on metrics, or resolved ambiguity across teams.
DoorDash Data Scientist Interview Guide | Sample Questions (2025)
Tell me about one of your favorite projects. · How do you work with non-technical stakeholders? · How do you prioritize your work? · How do you handle differences ...
8 DoorDash SQL Interview Questions (Updated 2025) - DataLemur
What Do DoorDash Data Science Interviews Cover? · Probability & Statistics Questions · Python or R Programming Questions · A/B testing Questions ...
DoorDash Data Scientist Interview Question - YouTube
In today's video, let's delve into a common merchant acquisition question asked during DoorDash Data Science interviews.
Most Common DoorDash Data Scientist Interview Questions
DoorDash data scientist interviews test SQL knowledge, including ISODOW, ntile, WINDOW functions, date/time extraction, AVG/SUM, and WHERE/ ...
This interview preparation guide was generated using AI-powered research from the sources listed above. While we strive for accuracy, we recommend verifying critical information from official company sources.
Want to create your own tailored preparation guide using our deep research?
Get Started for FreeInterview-Ready Courses
Visual-first, interactive, structured learning paths