# Watermark (Stream Processing)

> A line that says no older events are expected now.

**Field:** Data Engineering  
**Category:** Processing  
**Also known as:** Watermark, Event-Time Watermark

## Think of it like

It is like a teacher saying the test is closed. Papers that come in after that are marked late.

## Definition

A watermark is a stream's guess of how far event time has got. It says no more events older than this time are expected. When the watermark passes the end of a window, the window is closed and its result is sent. A watermark is often set as the newest event time minus a delay, such as five minutes. A longer delay catches more late events but sends results later.

## Example

With a 5-minute watermark, the 10:00 to 10:05 window closes once an event stamped 10:10 has been seen.

## Example code

```sql
CREATE TABLE clicks (
  page STRING,
  ts   TIMESTAMP(3),
  WATERMARK FOR ts AS ts - INTERVAL '5' SECOND
) WITH ('connector' = 'kafka', ...);
```

In Flink SQL, the watermark trails the newest event time by five seconds.

## Why it matters

Without it, a stream would never know when to give a final count. It sets the trade between being right and being fast.

## Common mistake

Setting the delay too short. Many real events arrive after it and are thrown away.

## Three principles

- **How far event time got.** A best guess.
- **Closes windows.** Then results are sent.
- **Delay is a trade.** More right or more fast.

## Related terms

- [Event Time](https://learn.benibix.com/term/data/event-time)
- [Late-Arriving Data](https://learn.benibix.com/term/data/late-arriving-data)
- [Windowing (Stream Processing)](https://learn.benibix.com/term/data/windowing)
- [Apache Flink](https://learn.benibix.com/term/data/apache-flink)
- [Spark Structured Streaming](https://learn.benibix.com/term/data/spark-structured-streaming)

![Events on a line by the time they happened, with a second line for the time they arrived. One event happened early but arrives late. A watermark line moves along behind the newest event; the late event that arrives after the watermark has passed its window is marked late.](https://learn.benibix.com/diagrams/event-time-watermark.svg)

---

Source: https://learn.benibix.com/term/data/watermark
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
