Sessionizing Eats App Events Into an Ordered Checkout Funnel
Last updated: November 29, 2026
Quick Overview
From a raw app events table, split each eater's events into sessions using a 30-minute inactivity gap, then compute the store view to add-to-cart to checkout funnel, counting a step only if it happens after the previous step in the same session.
Uber
November 29, 20260
0
0 solved
From a raw app events table, split each eater's events into sessions using a 30-minute inactivity gap, then compute the store view to add-to-cart to checkout funnel, counting a step only if it happens after the previous step in the same session.
Session funnels are core to Uber Eats product analytics, and the ordered version is a common onsite SQL problem. The interviewer checks gap-based session IDs with window functions and strict step ordering.
What the Interviewer Expects
- Use LAG to find gaps between consecutive events per eater
- Create session IDs with a running SUM of new-session flags
- Find the first timestamp of each step per session
- Enforce step order with timestamp comparisons
- Report conversion rates with safe division
Key Topics to Cover
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
- How would you handle sessions that span midnight?
- What if the same eater uses two devices at once?
- How would you compute median time from view to checkout?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice SQL ProblemsSample Answer
Clarify the Data
app_events(eater_id, event_ts, event_name). A new session starts when the gap to the previous event exceeds 30 minutes. Funnel steps: store_view, add_to_cart, checkout. A checkout counts only ...
Approach
LAG(event_ts)per eater gives the previous timestamp.- Flag a new session when there is no previous event or the gap is over 30 minutes.
- Running
SUMof the flag gives a session number. - ...