WindowFunction class

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

A function that is evaluated over a window frame of documents, as part of an Pipeline.addWindowFields() stage.

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

A WindowFunction is created either by one of the dedicated window function factories (such as rank()), or by calling over() on an AggregateFunction.

Signature:

export declare class WindowFunction 

Constructors

Constructor Modifiers Description
(constructor)(name, params) (Public Preview) Constructs a new instance of the WindowFunction class

Properties

Property Modifiers Type Description
exprType ExpressionType (Public Preview)

Methods

Method Modifiers Description
as(name) (Public Preview) Assigns an alias to this WindowFunction. The alias specifies the name that the computed value will have in the output document.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
over(frame) (Public Preview) Evaluates this window function over a specific window frame, rather than over the window frame defined by the enclosing Pipeline.addWindowFields() stage.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-notesThe backend only accepts a frame (documents or range) here, and rejects partition and sort, which must be specified on the enclosing addWindowFields() stage.- In a documents frame, bounds are document offsets relative to the current document's position ('current' refers strictly to the current document's position; tied documents are not included). For preceding, a positive integer (e.g. 2) includes up to that many documents before the current document, and a negative integer (e.g. -1) indicates a boundary following the current document, enabling frames that start after the current document. For following, a positive integer (e.g. 2) includes up to that many documents after the current document, and a negative integer (e.g. -1) indicates a boundary preceding the current document, enabling frames that end before the current document (e.g. excluding the current document). - In a range frame, bounds are value or time offsets relative to the current document's sort value(s) ('current' is peer-inclusive and includes all documents tied with the current document's sort value(s), equivalent to an offset of 0). For preceding, a positive offset subtracts from the current document's sort value (looking into the past), and a negative offset adds to the current document's sort value (shifting the lower boundary past the current document). For following, a positive offset adds to the current document's sort value (looking into the future), and a negative offset subtracts from the current document's sort value (shifting the upper boundary before the current document). Range frames with numeric or time-unit offsets require a single numeric or timestamp sort ordering on the enclosing stage, whereas range frames bounded only by 'current' and 'unbounded' support multiple sort orderings and non-numeric sort values.

WindowFunction.(constructor)

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Constructs a new instance of the WindowFunction class

Signature:

constructor(name: string, params?: Expression[]);

Parameters

Parameter Type Description
name string
params Expression[]

WindowFunction.exprType

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Signature:

exprType: ExpressionType;

WindowFunction.as()

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Assigns an alias to this WindowFunction. The alias specifies the name that the computed value will have in the output document.

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

Signature:

as(name: string): AliasedWindowFunction;

Parameters

Parameter Type Description
name string The alias to assign to this WindowFunction.

Returns:

AliasedWindowFunction

A new AliasedWindowFunction.

WindowFunction.over()

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Evaluates this window function over a specific window frame, rather than over the window frame defined by the enclosing Pipeline.addWindowFields() stage.

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 backend only accepts a frame (documents or range) here, and rejects partition and sort, which must be specified on the enclosing addWindowFields() stage.

  • In a documents frame, bounds are document offsets relative to the current document's position ('current' refers strictly to the current document's position; tied documents are not included). For preceding, a positive integer (e.g. 2) includes up to that many documents before the current document, and a negative integer (e.g. -1) indicates a boundary following the current document, enabling frames that start after the current document. For following, a positive integer (e.g. 2) includes up to that many documents after the current document, and a negative integer (e.g. -1) indicates a boundary preceding the current document, enabling frames that end before the current document (e.g. excluding the current document). - In a range frame, bounds are value or time offsets relative to the current document's sort value(s) ('current' is peer-inclusive and includes all documents tied with the current document's sort value(s), equivalent to an offset of 0). For preceding, a positive offset subtracts from the current document's sort value (looking into the past), and a negative offset adds to the current document's sort value (shifting the lower boundary past the current document). For following, a positive offset adds to the current document's sort value (looking into the future), and a negative offset subtracts from the current document's sort value (shifting the upper boundary before the current document). Range frames with numeric or time-unit offsets require a single numeric or timestamp sort ordering on the enclosing stage, whereas range frames bounded only by 'current' and 'unbounded' support multiple sort orderings and non-numeric sort values.

Signature:

over(
    frame: OneOf<{
      documents: DocumentWindowFrame;
      range: RangeWindowFrame;
    }>
  ): WindowFunction;

Parameters

Parameter Type Description
frame OneOf<{ documents: DocumentWindowFrame; range: RangeWindowFrame; }> The documents or range window frame to evaluate this function over.

Returns:

WindowFunction

A new WindowFunction.