Stateful transformations operate on a DStream, but the computations depend on the previous state of processing. Operations such as countByValueAndWindow, reduceByKeyAndWindow , mapWithState, and updateStateByKey are all examples of stateful transformations. In fact, all window-based transformations are all stateful because, by the definition of window operations, we need to keep track of the window length and sliding interval of DStream.