Compute Effective Reads with SQL and Python Streaming
Company: Meta
Role: Data Scientist
Category: Data Manipulation (SQL/Python)
Difficulty: medium
Interview Round: Onsite
Overview: This question evaluates proficiency in event-level data aggregation, sessionization, windowing, and stateful stream processing across SQL and Python, including computing aggregated metrics such as total watch duration and peak screen coverage.
Tables
post_read_events(event_id INTEGER, user_id INTEGER, session_id VARCHAR(20), post_id INTEGER, watch_duration_sec DECIMAL(6,2), screen_coverage_pct INTEGER, event_timestamp TIMESTAMP)
Hints
- Collapse the event log to one row per post with GROUP BY post_id before applying any thresholds.
- Use SUM(watch_duration_sec) for total watch time and MAX(screen_coverage_pct) for peak coverage, then filter both with a single HAVING clause.