← Twitch Interview Insights

Twitch·Data Scientist·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Jun 2026Remote

Summary

SQL-heavy technical screen for a Data Scientist role at Twitch, all revolving around two streaming tables. Four questions, each building on the last, and the multi-year edge case stuff caught me more off guard than I'd like to admit.

Questions Asked (4)

Q1

Using the minute_streamed table, write a query that returns total hours streamed for each calendar month, ordered chronologically. Also explain how your query handles data that spans multiple years.

Product Analytics & MetricsData Modeling
Author's notes

Went straight to COUNT(*)/60 grouped by month and forgot to include year in the group-by key.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the schema of minute_streamed (e.g., timestamp column, minutes streamed per row). Then write a SQL query that truncates the timestamp to the month level, sums the minutes, converts to hours, and orders by month. Finally, explain how the date truncation naturally handles multi-year data by including the year in the grouping.

Pro tip: Mention that using DATE_TRUNC('month', timestamp) is more robust than extracting month alone because it preserves the year, and consider time zone implications if the data is stored in UTC.

1. Clarify the table schema

Ask or state assumptions about the columns in minute_streamed, such as a timestamp column (e.g., streamed_at) and a numeric column for minutes streamed (e.g., minutes).

2. Aggregate minutes by month

Use DATE_TRUNC('month', streamed_at) to group records into calendar months, then SUM(minutes) to get total minutes per month.

3. Convert to hours and order

Divide the total minutes by 60 to get hours, and order the results by the truncated month in ascending order.

4. Explain multi-year handling

Highlight that DATE_TRUNC includes the year, so months from different years are separate groups, ensuring chronological ordering across years.

Key Points to Mention

  • Use DATE_TRUNC('month', timestamp) to group by calendar month while preserving the year.
  • Sum the minutes streamed and divide by 60 to convert to hours.
  • Order by the truncated month to ensure chronological order across multiple years.
  • Consider time zone conversion if the timestamp is in UTC and reporting is in local time.
  • Mention that if the table stores seconds instead of minutes, adjust the conversion accordingly.
  • Discuss potential edge cases like incomplete months or missing data.

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

Q2

For each streamer, compute their total streamed hours and the percentage of those hours spent streaming content in a category that matches a given keyword. The match should be case-insensitive.

Product Analytics & MetricsData Modeling
Author's notes

The percentage part tripped me up a bit.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the data model and assumptions, then outline a SQL or pandas solution that aggregates total hours per streamer and computes the percentage of hours in matching categories using a case-insensitive keyword match. Emphasize handling edge cases like nulls, multiple categories per stream, and ensuring the percentage is calculated correctly as a ratio of sums.

Pro tip: Mention that you would validate the keyword match logic with a quick sample query and consider performance implications for large datasets, such as using indexing or pre-filtering. Also, discuss how you might handle multiple keywords or partial matches if the requirement evolves.

1. Clarify Requirements and Data Model

Ask clarifying questions about the data schema: how stream sessions are recorded, whether each session has a single category, and how hours are calculated. Confirm that 'total streamed hours' means sum of hours across all sessions per streamer.

2. Design the Aggregation Logic

Plan to group by streamer to compute total hours. For the percentage, sum hours where the category matches the keyword (case-insensitive) and divide by total hours, multiplying by 100.

3. Implement Case-Insensitive Matching

Use LOWER() or ILIKE in SQL, or str.lower() in pandas, to match the keyword against the category. Ensure the keyword is also lowercased for consistency.

4. Handle Edge Cases and Validate

Address null categories, streamers with zero hours, and potential duplicate sessions. Validate results with a small sample or by cross-checking totals.

5. Present the Solution and Discuss Scalability

Write the final query or code clearly, and mention performance considerations like indexing on streamer_id and category, or using approximate methods for large-scale data.

Key Points to Mention

  • Case-insensitive matching using LOWER() or ILIKE
  • Aggregation with GROUP BY streamer_id and SUM of hours
  • Percentage calculation as (matching_hours / total_hours) * 100
  • Handling NULL categories or missing data
  • Performance optimization for large datasets (indexes, partitioning)
  • Validation of results with sample data or sanity checks

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

Q3

Identify all streamers whose total streamed hours in a given month exceeded their total from the prior month. Your solution needs to handle multiple years of data and months where a streamer had no activity at all.

Product Analytics & MetricsAlgorithms & Data Structures
Author's notes

This one took the most time.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the data schema and defining 'streamed hours' and 'month' precisely. Then outline an algorithm that aggregates hours per streamer per month, handles missing months by treating them as zero, and compares each month's total to the prior month's total, ensuring correct year-over-year handling. Finally, discuss edge cases like streamers with no activity in either month and how to efficiently process large datasets.

Pro tip: Mention that you would validate the results by spot-checking a few streamers and also consider the business context—e.g., whether to include only live hours or also reruns—to show you think beyond the code.

1. Clarify requirements and data schema

Ask questions to confirm the definition of 'streamed hours' (e.g., live vs. total watch time), the time granularity (month), and the data sources. Ensure you understand how to handle multiple years and missing months.

2. Aggregate hours per streamer per month

Group the data by streamer ID and month (including year) and sum the streamed hours. This creates a complete timeline for each streamer, filling in missing months with zero hours.

3. Compare each month to the prior month

For each streamer, compute the previous month's total (using a window function like LAG or a self-join) and filter for rows where the current month's hours exceed the previous month's hours.

4. Handle edge cases and validate

Ensure that streamers with no activity in the prior month are treated as having zero hours, and that year boundaries are handled correctly. Validate results with sample checks and consider performance optimizations for large datasets.

Key Points to Mention

  • Use of window functions (e.g., LAG) or self-joins to compare consecutive months
  • Handling missing months by treating them as zero activity
  • Correctly partitioning by streamer and ordering by year-month
  • Definition of 'streamed hours' and potential ambiguities (e.g., live vs. total hours)
  • Scalability considerations for large datasets (e.g., partitioning, indexing)
  • Validation and sanity checks to ensure accuracy

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

Q4

Join minute_streamed and minute_viewed to produce, per streamer, their average concurrent viewers in 2019 and the total minutes watched by viewers from the US in 2019.

Product Analytics & MetricsData Modeling
Author's notes

Straightforward join but the two aggregations live on different tables so you have to be careful not to fan out rows before aggregating.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First clarify the grain of each table and the join key (likely streamer_id and minute timestamp). Then filter both tables to 2019, join on streamer_id and minute, and compute the two metrics: average concurrent viewers per streamer and total US watch minutes. Use appropriate aggregation and handle potential duplicates or missing data.

Pro tip: Be explicit about the join type and grain: an inner join on streamer_id and minute ensures you only count minutes where both streaming and viewing occurred, avoiding inflated averages. Also, clarify whether 'average concurrent viewers' should be computed as total viewer-minutes divided by total streamed minutes or as an average of per-minute counts—the former is more accurate for concurrency.

1. Understand the data and define metrics

Examine the schema of minute_streamed and minute_viewed to identify join keys, time fields, and viewer counts. Clarify definitions: average concurrent viewers = total viewer-minutes / total streamed minutes per streamer; total US watch minutes = sum of minutes watched by US viewers.

2. Filter to 2019 and prepare tables

Filter both tables to records in 2019 using the appropriate date/timestamp column. Ensure streamer_id and minute are consistent types for joining.

3. Join the tables

Join minute_streamed and minute_viewed on streamer_id and minute (inner join) to align streaming minutes with viewing minutes. This ensures each row represents a minute where the streamer was live and viewers were watching.

4. Aggregate per streamer

Group by streamer_id. For average concurrent viewers, compute SUM(viewer_count) / COUNT(DISTINCT minute) or SUM(viewer_count) / SUM(stream_minutes) depending on table structure. For US watch minutes, filter viewer_country = 'US' and sum viewer_minutes (or count of minutes).

5. Validate and present results

Check for anomalies (e.g., streamers with zero minutes, negative values). Present results clearly, noting any assumptions made about the data or metric definitions.

Key Points to Mention

  • Grain of the tables: minute_streamed likely has one row per streamer per minute live; minute_viewed has one row per streamer per minute per viewer or aggregated viewer count.
  • Join key: streamer_id and minute timestamp; use INNER JOIN to avoid counting minutes where streamer wasn't live.
  • Average concurrent viewers: total viewer-minutes divided by total streamed minutes, not a simple average of averages.
  • US watch minutes: filter viewer_country = 'US' and sum minutes watched (or count of viewer-minutes).
  • Time filtering: use 2019 date range on the minute timestamp, considering time zones if applicable.
  • Handling missing data: decide whether to exclude streamers with no views or include zeros, and document the choice.

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