Incremental Daily Sessionization That Carries Open Sessions Forward
Last updated: November 29, 2026
Quick Overview
A daily pipeline sessionizes WhatsApp app events one date partition at a time. Write the step that takes the previous day's still-open sessions plus today's events, emits sessions that are final, and carries forward sessions that could still continue past midnight.
Meta
November 29, 20260
0
0 solved
A daily pipeline sessionizes WhatsApp app events one date partition at a time. Write the step that takes the previous day's still-open sessions plus today's events, emits sessions that are final, and carries forward sessions that could still continue past midnight.
A pipeline-design flavored coding question in the style of Meta's data engineering onsite, where daily partitions are processed incrementally rather than rebuilt from history. The interviewer checks that sessions crossing a partition boundary are neither split nor double counted, and that the carried state is small and well defined.
What the Interviewer Expects
- Merges carried open sessions with today's events per user
- Applies the gap rule across the partition boundary
- Finalizes a session only when it cannot be extended
- Carries forward only sessions within the gap of the partition end
- Flushes carried sessions for users with no events today
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 represent the carried state as a table in the warehouse?
- What happens if a partition is backfilled after the next day already ran?
- How would late-arriving events change the finalization rule?
- How would you test idempotency of this step?
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
State carried from yesterday is {user: (start, last_ts, n_events)} for sessions whose last event was within 30 minutes of yesterday's end. Today's input is (user, ts) events in seconds and the par...
Approach
For every user that has carried state or events today, start from the carried session and walk today's sorted events. Within the gap, extend; otherwise close the current session and start a new one. A...