> Documentation index: https://firebase.google.com/docs/reference/llms.txt

# WindowFunction


```
@Beta
class WindowFunction
```

<br />

*** ** * ** ***

A class that represents a window function.

Window Functions SDK features are in preview until the backend feature launches. Look for launch announcement at: https://docs.cloud.google.com/firestore/docs/release-notes

## Summary

| ### Public companion functions |
|---|---|
| `WindowFunction` | `@Beta rank()` Returns the rank of each document within its partition according to the window's sort order. |

| ### Public functions |
|---|---|
| `AliasedWindowFunction` | `@Beta alias(alias: String)` Assigns an alias to this window function. |
| `open operator Boolean` | `equals(other: Any?)` |
| `open Int` | `hashCode()` |
| `WindowFunction` | `@Beta over(window: WindowSpec)` Evaluates this function over an explicit window frame. |

## Public companion functions

### rank

```
@Beta
fun rank(): WindowFunction
```

Returns the rank of each document within its partition according to the window's sort order. Documents with equal sort values receive the same rank, and the following rank is skipped. The window must specify exactly one sort ordering.

Window Functions SDK features are in preview until the backend feature launches. Look for launch announcement at: https://docs.cloud.google.com/firestore/docs/release-notes

| Returns |
|---|---|
| `WindowFunction` | A new `WindowFunction` representing the rank window function. |

## Public functions

### alias

```
@Beta
fun alias(alias: String): AliasedWindowFunction
```

Assigns an alias to this window function.

Window Functions SDK features are in preview until the backend feature launches. Look for launch announcement at: https://docs.cloud.google.com/firestore/docs/release-notes

| Parameters |
|---|---|
| `alias: String` | The alias to assign to this window function. |

| Returns |
|---|---|
| `AliasedWindowFunction` | A new `AliasedWindowFunction` that wraps this window function and associates it with the provided alias. |

### equals

```
open operator fun equals(other: Any?): Boolean
```

### hashCode

```
open fun hashCode(): Int
```

### over

```
@Beta
fun over(window: WindowSpec): WindowFunction
```

Evaluates this function over an explicit window frame.

Window Functions SDK features are in preview until the backend feature launches. Look for launch announcement at: https://docs.cloud.google.com/firestore/docs/release-notes

The returned function carries its own framing, overriding the window declared on the enclosing `addWindowFields` stage. Only `documents` or `range` window frames (created via `WindowSpec.documents` or `WindowSpec.range`) are supported on individual accumulators; other window parameters such as `WindowSpec.partition` or `WindowSpec.sort` are not supported on accumulator-level `over()` and must be specified on the enclosing `addWindowFields` stage.

| Parameters |
|---|---|
| `window: WindowSpec` | The window frame specification to evaluate this function over. |

| Returns |
|---|---|
| `WindowFunction` | A new `WindowFunction` with the given framing. |