> For the complete documentation index, see [llms.txt](https://docs.pinot.apache.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pinot.apache.org/release-1.3.0/for-users/user-guide-query/multi-stage-query/operator-types/window.md).

# Window

The window operator is used to define a window over which to perform calculations.

This page describes the window operator defined in the relational algebra used by multi-stage queries. This operator is generated by the multi-stage query engine when you *window functions* in a query. You can read more about window functions in the [windows functions](/release-1.3.0/for-users/user-guide-query/query-syntax/windows-functions.md) reference documentation.

Unlike the [aggregate operator](/release-1.3.0/for-users/user-guide-query/multi-stage-query/operator-types/aggregate.md), which will output one row per group, the window operator will output as many rows as input rows.

## Implementation details

Window operators take a single input relation and apply window functions to it. For each input row, a window of rows is calculated and one or many aggregations are applied to it.

In general window operator are expensive in terms of CPU and memory usage, but they open the door to a wide range of analytical queries.

### Blocking nature

The window operator is a blocking operator. It needs to consume all the input data before emitting the result.

## Hints

Window hints are configured with the `windowOptions` hint, which accepts as argument a map of options and values.

For example:

```sql
SELECT
/*+  windowOptions(option1='value1', option2='value2') */
    col1, SUM(intCol) OVER() as sum FROM table
```

### max\_rows\_in\_window

Type: Integer

Default: 1048576

Max rows allowed to cache the rows in window for further processing.

### window\_overflow\_mode

Type: THROW or BREAK

Default: 'THROW'

Mode when window overflow happens, supported values:

* `THROW`: Break window cache build process, and throw exception, no further WINDOW operation performed.
* `BREAK`: Break window cache build process, continue to perform WINDOW operation, results might be partial.

## Stats

### executionTimeMs

Type: Long

The summation of time spent by all threads executing the operator. This means that the wall time spent in the operation may be smaller that this value if the parallelism is larger than 1. This number is affected by the number of received rows and the complexity of the window function.

### emittedRows

Type: Long

The number of groups emitted by the operator. A large number of emitted rows can indicate that the query is not well optimized.

Unlike the [aggregate operator](/release-1.3.0/for-users/user-guide-query/multi-stage-query/operator-types/aggregate.md), which will output one row per group, the window operator will output as many rows as input rows.

### maxRowsInWindowReached

Type: Boolean

This attribute is set to `true` if the maximum number of rows in the window has been reached.

## Explain attributes

The window operator is represented in the explain plan as a `LogicalWindow` explain node.

### window\#

Type: Expression

The window expressions used by the operator. There may be more than one of these attributes depending on the number of window functions used in the query, although sometimes multiple window function clauses in SQL can be combined into a single window operator.

The expression may use indexed columns (`$0`, `$1`, etc) that represent the columns of the virtual row generated by the upstream.

## Tips and tricks

None


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.pinot.apache.org/release-1.3.0/for-users/user-guide-query/multi-stage-query/operator-types/window.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
