Currently, the window operator blocks until all batches of current partition to be available. For some queries it's necessary (e.g. aggregate with no order-by in the window definition), but for other cases the window operator can process and pass the current batch downstream sooner.
Implementing this should help the window operator use less memory and run faster, especially in the presence of a limit operator.
The purpose of this JIRA is to improve the window operator in the following cases:
- aggregate, when order-by clause is available in window definition, can process current batch as soon as it receives the last peer row
- lead can process current batch as soon as it receives 1 more batch
- lag can process current batch immediately
- first_value can process current batch immediately
- last_value, when order-by clause is available in window definition, can process current batch as soon as it receives the last peer row
- row_number, rank and dense_rank can process current batch immediately
DRILL-3770 Query with window function having just ORDER BY clause runs out of memory on large datasets