D8LooPFocus modeCODE WORKSPACE
Return replay partitions for late or corrected source events.
Start by naming the output grain, then build CTEs that can be inspected one at a time.
Sample input
| event_id | event_time | ingested_at | is_correction |
|---|---|---|---|
| 502 | 2026-03-02 10:00:00 | 2026-03-05 09:00:00 | 0 |
| 503 | 2026-03-03 11:00:00 | 2026-03-05 10:00:00 | 1 |
| 505 | 2026-03-04 14:00:00 | 2026-03-06 02:00:00 | 0 |
Expected output
| partition_day | records_to_replay | latest_arrival_at |
|---|---|---|
| 2026-03-02 | 1 | 2026-03-05 09:00:00 |
| 2026-03-03 | 1 | 2026-03-05 10:00:00 |
| 2026-03-04 | 1 | 2026-03-06 02:00:00 |
Constraints
State the output contract first, use readable CTE layers, return the exact columns requested by the prompt, and use deterministic ordering.
Expected skills
Interview clarification, SQL structure, edge-case handling, and final-answer narration.
Run the SQL query to inspect preview rows.