Window functions are useful for processing tasks such as calculating a moving average, computing a cumulative statistic, or accessing the value of rows given the relative position of the current row
https://spark.apache.org/docs/latest/sql-ref-syntax-qry-select-window.html