← Snowflake Interview Insights

Snowflake·Data Scientist·Technical Phone Screen·Senior

Senior
Jun 2026Remote

Summary

Technical screen for a Data Scientist role at Snowflake. The whole thing was one big multi-part question combining BigQuery SQL, cohort analysis, and a Streamlit app build. Dense and exhausting, but kind of interesting if you're into that stuff.

Questions Asked (4)

Q1

Write a single BigQuery query using window functions with PARTITION BY that produces a cohort retention heatmap table with columns for signup week, week index, country, cohort size, retained users, and retention rate. Explain how you avoid double-counting users across weeks and handle users with late-arriving events.

Data ModelingProduct Analytics & MetricsTechnical Trade-offs
Author's notes

This is the kind of question where you feel fine until you actually try to write it.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the retention definition (e.g., active in week N after signup) and the data model (events table with user_id, event_timestamp, country). Then outline a query that computes each user's signup week, assigns a week index to each activity week, and uses window functions with PARTITION BY to count distinct retained users per cohort-week-country, finally calculating retention rate. Explain how you avoid double-counting by using COUNT(DISTINCT user_id) and handle late-arriving events by using event timestamps and possibly a lookback window or periodic refresh.

Pro tip: Mention that you would materialize the cohort assignments and use a scheduled query to handle late-arriving data, and that you'd validate the retention rates against a known benchmark to catch double-counting or missing data issues.

1. Define retention and cohort

Clarify what constitutes retention (e.g., any activity in the week) and how cohorts are defined (e.g., by signup week). Ensure alignment with stakeholders on the metric.

2. Compute signup week and week index

For each user, determine their signup week (first activity week) and for each activity, compute the week index relative to signup. Use DATE_TRUNC and date differences.

3. Aggregate retained users with window functions

Use COUNT(DISTINCT user_id) OVER (PARTITION BY signup_week, week_index, country) to count retained users per cohort-week-country, ensuring each user is counted once per week.

4. Calculate retention rate and handle late events

Compute retention rate as retained users / cohort size. For late-arriving events, use event timestamps and consider a lookback window or periodic recomputation to update historical cohorts.

5. Validate and explain trade-offs

Validate results by checking cohort sizes and retention curves. Discuss trade-offs between accuracy and latency, and how you'd handle edge cases like users with no activity after signup.

Key Points to Mention

  • Use COUNT(DISTINCT user_id) to avoid double-counting users who have multiple events in a week.
  • PARTITION BY signup_week, week_index, country to compute cohort metrics.
  • Handle late-arriving events by using event timestamps and possibly a lookback window or scheduled refresh.
  • Define cohort size as the number of unique users who signed up in that week and country.
  • Consider using a calendar table or date spine to ensure all weeks are represented, even with no activity.
  • Discuss trade-offs between using a single query vs. materializing intermediate tables for performance and maintainability.

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

Q2

Extend the cohort retention SQL to compute weekly ARPU by cohort and country, ensuring users with no purchases still count in the cohort size but contribute zero to revenue.

Data ModelingProduct Analytics & MetricsTechnical Trade-offs
Author's notes

LEFT JOIN from the cohort table to purchases is the obvious move, and I got that right.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the cohort definition and the grain of the output (cohort week × country × week number). Then build the query in layers: first compute cohort sizes including all users, then aggregate revenue from purchasers, and finally left join and divide to get ARPU while handling zero revenue and nulls.

Pro tip: Explicitly state that you would use a LEFT JOIN from cohort members to revenue and COALESCE the revenue to zero, and mention that you'd validate the query by checking that total revenue matches a separate aggregation and that ARPU is zero for cohorts with no purchasers.

1. Clarify requirements and define cohort

Confirm the cohort definition (e.g., users grouped by first activity week) and the output grain (cohort_week, country, week_number). Ensure that all users in the cohort are counted, regardless of purchases.

2. Compute cohort sizes including all users

Create a CTE that assigns each user to a cohort and country, then aggregates to get the total number of users per cohort and country. This will be the denominator for ARPU.

3. Aggregate revenue by cohort, country, and week

Create a second CTE that sums purchase revenue per user per week, then joins to the cohort mapping to get revenue by cohort, country, and week number. Only users with purchases will appear here.

4. Left join and compute ARPU

Left join the cohort sizes to the revenue aggregation on cohort_week, country, and week_number. Use COALESCE to replace null revenue with 0, then divide revenue by cohort size to get ARPU.

5. Validate and handle edge cases

Check that total revenue matches a separate aggregation, and that ARPU is 0 for cohorts with no purchasers. Consider whether to use integer division or cast to float, and handle any timezone or date truncation issues.

Key Points to Mention

  • Cohort definition and grain: clarify how cohorts are defined (e.g., first purchase week vs. first activity week) and the output grain.
  • LEFT JOIN vs. INNER JOIN: use LEFT JOIN to ensure all cohort members are included, with zero revenue for non-purchasers.
  • COALESCE or IFNULL: replace null revenue with 0 before division to avoid null ARPU.
  • Denominator: cohort size should be the total number of users in the cohort and country, not just purchasers.
  • Week numbering: define week_number as periods since cohort start (e.g., 0 for acquisition week, 1 for next week).
  • Validation: cross-check total revenue and ensure ARPU is zero when there are no purchases.

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

Q3

Build a Streamlit app that lets a user filter by country and toggle between a retention heatmap and an ARPU line chart, treats missing future weeks as NA rather than zero, masks cohorts below 50 users, and includes a UTC offset selector that re-buckets events by timezone without duplicating users across weeks.

System DesignProduct Analytics & MetricsTechnical Trade-offs
Author's notes

The masking and NA vs zero distinction are easy wins if you remember them.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the data model and metric definitions, then walk through the app architecture: data ingestion, transformation, and visualization layers. Emphasize how you handle timezone re-bucketing, missing data, and privacy thresholds, and discuss trade-offs between correctness and performance.

Pro tip: Mention that you would validate the timezone re-bucketing logic with unit tests on edge cases (e.g., events near week boundaries) to ensure no user duplication, and use Snowflake's timezone functions for consistency.

1. Clarify Requirements and Data Model

Ask about the event data schema, cohort definition, and metric formulas (retention, ARPU). Confirm that 'missing future weeks' means weeks after the current date for a cohort, and that masking cohorts below 50 users is for privacy.

2. Design Data Pipeline and Transformations

Outline how to compute cohorts and weekly metrics in Snowflake, handling timezone conversion by adjusting event timestamps to the selected UTC offset before bucketing into weeks. Ensure each user is assigned to exactly one week per cohort period.

3. Implement Streamlit UI and Visualizations

Use Streamlit widgets for country filter, chart toggle, and UTC offset selector. Generate a retention heatmap and ARPU line chart, applying NA for missing future weeks and masking cohorts with <50 users.

4. Address Trade-offs and Performance

Discuss caching strategies, query optimization (e.g., pre-aggregation), and the impact of timezone re-bucketing on query complexity. Consider using Snowpark or SQL for transformations.

5. Test and Validate

Describe how you would test the timezone logic, missing data handling, and masking. Suggest unit tests for edge cases and validation against known metrics.

Key Points to Mention

  • Timezone re-bucketing: convert event timestamps to the selected UTC offset before assigning to weeks, ensuring no user appears in multiple weeks.
  • Missing future weeks: represent as NA (not zero) to avoid misleading trends, and handle in visualization (e.g., heatmap with blank cells).
  • Cohort masking: suppress cohorts with fewer than 50 users to protect privacy and avoid noise.
  • Retention heatmap: typically shows percentage of users returning in subsequent weeks, with cohorts as rows and weeks as columns.
  • ARPU line chart: average revenue per user over time, aggregated by week and filtered by country.
  • Streamlit interactivity: use st.selectbox, st.radio, and st.slider for filters; st.plotly_chart or st.altair_chart for visualizations.
  • Snowflake-specific: leverage timezone functions (CONVERT_TIMEZONE) and window functions for cohort analysis.

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

Q4

Describe two data quality checks you would build into the app, such as verifying cohort size monotonicity across observed weeks and guarding against clock skew that produces negative week index values.

Root Cause AnalysisProduct Analytics & Metrics
Author's notes

Negative week_index was the one I actually had a concrete answer for.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by framing data quality checks as essential for trustworthy analytics, then describe two specific checks: cohort size monotonicity and clock skew detection. For each, explain the check, its implementation, and how it prevents downstream errors.

Pro tip: Tie each check to a real-world impact, like avoiding incorrect retention metrics or negative time indices, to show business awareness. Mention that these checks should be automated and alert on failure to maintain data integrity at scale.

1. Introduce the importance of data quality

Briefly explain why data quality checks are critical in product analytics, especially for cohort-based metrics and time-series analysis.

2. Describe cohort size monotonicity check

Explain that cohort sizes should never increase over time; implement a check that compares cohort sizes across weeks and alerts if any later week has a larger size than an earlier week.

3. Describe clock skew detection check

Explain that negative week indices indicate clock skew; implement a check that flags any negative values in week index calculations and logs the event for investigation.

4. Explain implementation and automation

Mention that these checks should be automated in the data pipeline, with alerts sent to the data team when violations occur, and possibly integrated with data quality frameworks like Great Expectations.

5. Highlight impact and mitigation

Discuss how these checks prevent incorrect metrics, such as inflated retention rates or negative time-based features, and outline steps to mitigate issues when detected.

Key Points to Mention

  • Cohort size monotonicity: cohort sizes should be non-increasing over time; violation indicates data loss or duplication.
  • Clock skew: negative week indices arise from timestamps earlier than cohort start; check for and correct timezone or system clock issues.
  • Automated data quality checks in ETL/ELT pipelines to catch issues early.
  • Use of data quality frameworks (e.g., Great Expectations, dbt tests) for scalable validation.
  • Impact on metrics: incorrect cohort sizes skew retention, churn, and LTV calculations.
  • Alerting and logging mechanisms to notify data teams for rapid resolution.

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