Late data
Pattern. Events that arrive after the watermark has passed their window. ArkFlow handles them at the source boundary with a declared policy, not inside SQL.
Where late data is decided
Late handling is a source (Job time) declaration:
| Policy | Behavior |
|---|---|
drop | The late row is dropped and acknowledged. |
route | The late row is emitted on the late-event side output. |
update | A window still inside its allowed-lateness period is corrected and re-emitted with the __arkflow_window_update marker column. |
Within a batch the watermark advances before classification, so a batch of
[2100, 100] treats 100 as late immediately. Null timestamps follow the
same route as late events (route) or are dropped.
SQL patterns on the late side output
Route late events to the side output and process them as a separate stream. Typical SQL over the side output:
-- Audit: how much data is arriving late, per source hour
SELECT date_trunc('hour', __meta_timestamp) AS hour, count(*) AS late_rows
FROM flow
GROUP BY date_trunc('hour', __meta_timestamp)
-- Reconstruct the corrected view: keep the latest update per window/key
SELECT window_start, key, value, __arkflow_window_update
FROM (
SELECT window_start, key, value, __arkflow_window_update,
row_number() OVER (PARTITION BY window_start, key ORDER BY __meta_timestamp DESC) AS rn
FROM flow
) ranked
WHERE rn = 1
The "latest per key" pattern is the same one as deduplication.
Expected result
- With
update, a corrected window re-emits the full corrected aggregate with__arkflow_window_updateset; downstream must treat it as a replacement, not an append. - With
route, the main output stays clean; the side output carries the raw late rows for audit or repair. - After the allowed-lateness period expires, the window buffer is cleaned up
and further updates follow
drop/route.
Boundaries
- The SQL processor cannot see whether a row was late — lateness is decided at the source before processing. Keep late handling out of per-batch SQL.
updaterequires the window to still be buffered; a correction after retention is a late event, not an update.