Write a query to deduplicate a streaming dataset where duplicate records can arrive up to 24 hours late.
Assume streaming_events contains a rolling input window. Use the latest ingested_at value as the watermark, include records ingested within the preceding 24 hours inclusively, and retain the earliest ingested row for each event_id. Use ingestion_id as the deterministic tie-breaker.
event_id, with columns event_id, event_time, ingested_at, and payloadevent_id, then ingestion_id ascending| Column | Type | Description |
|---|---|---|
| ingestion_idPK | BIGINT | Unique identifier for the ingested row |
| event_id | VARCHAR(64) | Logical identifier used to identify duplicate events |
| event_time | TIMESTAMPTZ | Time at which the event occurred |
| ingested_at | TIMESTAMPTZ | Time at which the streaming system received the row |
| payload | TEXT | Optional event payload |