Handling Late-Arriving Data
Design for data that arrives after its event window. Separate event and ingestion timestamps, track watermarks, and rebuild affected partitions through safe backfills.
Yesterday’s dashboard says 120 orders. This morning, a mobile client reconnects and uploads ten orders created yesterday. If the pipeline assigns them to today, the ingestion chart looks healthy while the business report is wrong.

Late-arriving data is normal when systems buffer, retry, reconnect, or deliver files on a schedule. Store when the event happened separately from when the platform received it, then define how published results change when those timestamps disagree.
Step 1: Keep Both Clocks
-- PostgreSQL example. Event timestamps are supplied by the source.
create table raw_events (
source text not null,
event_id text not null,
event_time timestamptz not null,
ingested_at timestamptz not null default now(),
amount numeric(18, 2) not null,
primary key (source, event_id)
);Use event_time for business attribution and ingested_at for delivery monitoring or incremental extraction. Preserve the source time zone or normalize to a documented convention. Define the business day explicitly; a reporting day in Karachi is not the same interval as a UTC calendar day.
Timestamp quality is a separate concern. Quarantine malformed or implausibly future-dated events and record the reason. Do not silently replace a missing event timestamp with the ingestion time and pretend the resulting business history is exact.
Step 2: Define the Lateness Policy
In streaming systems, a watermark estimates progress through event time. It does not prove that every earlier event has arrived. Windowing, allowed lateness, and triggers determine whether and when late events can update emitted results; state retention and runner behavior also matter.
Apache Beam event-time windows and late data
For a daily batch, a bounded lookback can reprocess the last few business days. Choose that interval from observed arrival delays and the cost of correction. A three-day lookback is an operating assumption, not a completeness guarantee for an event delayed by a month.
Step 3: Rebuild Affected Partitions
-- PostgreSQL: caller supplies timezone-aware boundaries for one UTC day.
-- Source input for the repair is frozen before this transaction starts.
begin;
delete from daily_revenue where day = :target_day;
insert into daily_revenue (day, total_amount)
select :target_day, coalesce(sum(amount), 0)
from raw_events
where event_time >= :day_start
and event_time < :day_end;
commit;This example replaces one aggregate instead of adding the late amount to an existing total. Repeating the repair over the same frozen input produces the same result. Serialize writers for that partition or use the warehouse’s supported atomic replacement mechanism; two concurrent repairs must not interleave unpredictably.
Step 4: Give Backfills a Separate Contract
Older data needs an explicit backfill path. Record the requested range, input snapshot or cutoff, transformation version, initiating actor, and output validation results. Limit concurrency so a repair does not starve the normal pipeline.
An incremental model filtered only on event_time greater than the target’s maximum event time can miss late events. Select newly ingested or updated records, identify their affected event dates, and rebuild those dates. Corrections and deletions can require the same process even when no new event identifier appears.
Publish the Meaning of the Number
Mark a report as provisional until its stated completeness threshold, and record revisions when a closed period is repaired. Some products need immutable published snapshots plus separate correction records; others can replace a current materialized result. Pick the policy with the report’s consumers.
Monitor arrival-lag distributions, rejected timestamps, late-event volume, and backfill outcomes. Test events exactly on a boundary, duplicates, a time-zone transition, and an event beyond the normal lookback. A late-data policy is useful only when the oldest exceptional event still has a repair path.