Streaming and bounded data joins

A stream grows without an end. A bounded table has a fixed set of rows. Many tables that you use for enrichment are bounded, or they change slowly, such as a table of products, customers, or currency rates.

Flink processes the join of a stream with such a table in the following ways:

  • A regular join keeps the rows of both inputs in state. It is simple, but the state grows if the stream is unbounded.
  • A temporal join treats the table as a versioned table. A versioned table contains a time attribute and a primary key, and it keeps the history of the rows. Each row of the stream is joined with the version of the table row that was valid at the time of the stream row.
  • A lookup join does not keep the table in state. It queries the external system for the latest row of each key when a row of the stream arrives.

A versioned table is a table whose rows change over a long time. A table of currency rates, for example, gets a new row at each change of a rate, and the earlier rates stay in the table. A join with this table returns the rate of the time of the order, not only the current rate.

You choose the time of the stream row:

Event time
The time when the event happened, taken from a column of the row. The join is deterministic, because a rerun gives the same result. You need a watermark on the stream. For more information, see Creating temporal joins and Event time and watermarks.
Processing time
The time at which Flink processes the row. The join uses the latest version of the table at that time. For more information, see Creating lookup joins.

For more information about versioned tables, see Versioned tables in the Apache Flink documentation.