Stateful functions and operators store data across the processing of individual elements/events, making state a critical building block for any type of more elaborate operation.
For example:
Flink needs to be aware of the state in order to make state fault tolerant using checkpoints and to allow savepoints of streaming applications.
Knowledge about the state also allows for rescaling Flink applications, meaning that Flink takes care of redistributing state across parallel instances.
The queryable state feature of Flink allows you to access state from outside of Flink during runtime.
When working with state, it might also be useful to read about Flink’s state backends. Flink provides different state backends that specify how and where state is stored. State can be located on Java’s heap or off-heap. Depending on your state backend, Flink can also manage the state for the application, meaning Flink deals with the memory management (possibly spilling to disk if necessary) to allow applications to hold very large state. State backends can be configured without changing your application logic.