Define two event-time DataStreams with watermarks; both streams must have watermarks assigned for interval join to advance correctly.
Use stream1.keyBy(keySelector1).intervalJoin(stream2.keyBy(keySelector2)).between(Time.minutes(-<lower>), Time.minutes(<upper>)).process(joinFunction).
The interval [lower, upper] specifies how far apart (relative to event time) two records from the two streams can be and still match.
Both streams buffer state until their respective watermarks advance past the join window boundary; size the state backend accordingly.
In Flink SQL, use an interval join in a WHERE clause: WHERE s1.event_time BETWEEN s2.event_time - INTERVAL '<lower>' AND s2.event_time + INTERVAL '<upper>'.
Test with synthetic data that has known join intervals to validate that matches are emitted and non-matches are discarded.
Known gotchas
Interval join state grows proportionally to the product of the two streams' arrival rates times the interval width; a wide interval on high-throughput streams can exhaust memory.
Late records beyond the interval bounds are silently dropped; if join miss rate is unexpectedly high, check watermark lag on both sides.
Interval join does not support outer semantics in the DataStream API (no LEFT or RIGHT interval joins); for optional matches you need a more complex pattern with process functions.
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp