PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches

Quick Overview

This question evaluates proficiency in event-driven data modeling, temporal state derivation, and implementation of SQL/Python logic to compute per-user subscription status and history within the Data Manipulation (SQL/Python) domain.

  • Medium
  • OpenAI
  • Data Manipulation (SQL/Python)
  • Data Scientist

Design Schema and Logic for Subscription Event Tracking

Company: OpenAI

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: Medium

Interview Round: Take-home Project

user_subscription_events +----------+-------------+---------------------+-----------+---------+ | user_id | event_type | event_time | plan_type | source | +----------+-------------+---------------------+-----------+---------+ | 101 | signup | 2023-05-01 09:03:12 | paid | web | | 101 | cancel | 2023-06-10 14:27:45 | paid | web | | 101 | signup | 2023-07-02 08:11:06 | paid | mobile | | 202 | signup | 2023-05-05 11:55:20 | paid | email | | 303 | cancel | 2023-05-07 16:02:09 | paid | support | +----------+-------------+---------------------+-----------+---------+ ##### Scenario Subscription event pipeline feeding the experiment: users can signup, cancel, then signup again; downstream tables drive metrics and triggering code. ##### Question Design the raw event table schema needed to derive a user's current subscription status and historical states. 2. Write SQL or Python logic that produces one row per user with their latest status, handling the edge case where a user signs up, cancels, and then signs up again. 3. Review the provided Python snippet that assigns variants and delivers the free-trial offer; identify at least three improvements or safeguards you would add. ##### Hints Think append-only event logs, window functions, deduping by latest timestamp, idempotent triggers.

Quick Answer: This question evaluates proficiency in event-driven data modeling, temporal state derivation, and implementation of SQL/Python logic to compute per-user subscription status and history within the Data Manipulation (SQL/Python) domain.

Last updated: Mar 29, 2026

Loading coding console...

PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Write SQL for repeat churn - OpenAI (hard)
  • Handle repeated churn in SQL - OpenAI (hard)
  • Compute churn with re-subscriptions - OpenAI (hard)
  • Debug and harden trial-assignment Python code - OpenAI (Medium)
  • Write SQL for post-trial conversion cohorts - OpenAI (Medium)