Skip to main content
Version: Next

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:

PolicyBehavior
dropThe late row is dropped and acknowledged.
routeThe late row is emitted on the late-event side output.
updateA 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_update set; 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.
  • update requires the window to still be buffered; a correction after retention is a late event, not an update.