Duplicate ingest rate by event type

mediumPipelines~15 min · 4 tests · ridelog

Before you fix duplicates, measure them. The ridelog collector sometimes stores an event twice. A copy has the same user_id, event_type and event_ts as the original, with a different event_id and ingested_at.

The pipeline team wants to know whether some event types are hit harder than others. Return one row per event_type with:

column type meaning
event_type text the event type
raw_rows integer rows in events for this type
unique_events integer distinct events after collapsing copies
duplicate_rows integer raw_rows - unique_events
duplicate_pct decimal 100 * duplicate_rows / raw_rows, rounded to 1 decimal

An event stored three times counts as one unique event and two duplicate rows.

Row order doesn’t matter.

Tables: events.

Learn the ideaRead the lesson →
solution.sqlDuckDB · ridelog

Press ⌘ ↵ or Run to check the visible tests. Submit runs the hidden ones too. Everything runs in your browser.

⌘ ↵ to run