Deduplicate Google Play Purchase Events to Each Order's Final Status

Last updated: November 29, 2026

Quick Overview

Google Play order events arrive with repeated and out-of-order status updates (pending, charged, refunded). Return each order's latest status and summarize orders and gross value by final status.

Google
Data Manipulation (SQL/Python)
Data Engineer
Google
November 29, 2026
Data Engineer
Phone Screen
Data Manipulation (SQL/Python)
Easy

0

0

0 solved


Google Play order events arrive with repeated and out-of-order status updates (pending, charged, refunded). Return each order's latest status and summarize orders and gross value by final status.

A practical deduplication question for Google data engineering phone screens, set in Play billing pipelines where retries and late events are common. The interviewer checks ROW_NUMBER with a solid tie-breaker and that you aggregate after deduping, not before.

What the Interviewer Expects
  • Partition by order and order by business update time descending
  • Break ties with ingestion time so the result is deterministic
  • Use QUALIFY or a subquery filter on row number 1
  • Aggregate only after selecting one row per order
  • Mention why MAX(status) or DISTINCT do not work
Key Topics to Cover
deduplication
ROW_NUMBER
QUALIFY
late-arriving data
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
  • Two events have the same updated_at but different statuses. What rule do you apply?
  • How would you make this incremental in a daily pipeline?
  • How would you detect orders whose status went backward, such as refunded to charged?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice SQL Problems
Sample Answer
Clarify the Data

play_purchase_events(order_id, user_id, sku, status, price_micros, updated_at, ingest_ts). The same update can be delivered twice (identical rows), and a later status can be ingested before an earli...

Approach

Rank each order's events by updated_at descending, with ingest_ts descending as a tie-breaker, and keep row number 1. That gives the true latest status even when events arrive out of order, and ex...


Submit Your Answer
Markdown supported