Repository navigation
feat(firestore): add support for window functions in Pipelines - #14504
Open
MarkDuckworth wants to merge 10 commits into
Open
MarkDuckworth wants to merge 10 commits into
MarkDuckworth wants to merge 10 commits into
Conversation
- Add AddWindowFields stage and Pipeline.addWindowFields overloads - Add WindowSpec, WindowBound, WindowFunction, and AliasedWindowFunction - Add AggregateFunction.over(WindowSpec) to evaluate aggregates over window frames - Add serialization and proto tests in AddWindowFieldsProtoTest and PipelineProtoTest - Add integration tests in ITPipelineTest with array_agg_distinct enabled against Nightly
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces support for window functions in the Firestore pipeline API, adding the addWindowFields stage along with supporting classes like WindowSpec, WindowFunction, WindowBound, and AliasedWindowFunction. It also includes extensive unit and integration tests to validate various windowing behaviors such as partitioning, sorting, and framing. A review comment suggests adding an explicit null check in WindowSpec.toBoundaryExpr to prevent potential serialization errors when a null boundary is provided.
- Replace the WindowBound enum with a final class exposing CURRENT/UNBOUNDED constants; remove the WindowSpec.CURRENT/UNBOUNDED aliases. - Remove WindowSpec.partition(FieldPath...) and the getPartition()/getSort() getters. - Document that CURRENT is peer-inclusive in range frames and positional in documents frames. - Add integration tests for tied peers, string and multi-key range sorts, and double range offsets.
…arkduckworth/window-functions
…gate comprehensive tests
MarkDuckworth
marked this pull request as ready for review
October 23, 2026 21:46
dlarocque
approved these changes
Oct 26, 2026
| } | ||
|
|
||
| /** | ||
| * Creates a window function that assigns a unique rank to each row based on the sort order. |
Contributor
There was a problem hiding this comment.
Suggested change
| * Creates a window function that assigns a unique rank to each row based on the sort order. | |
| * 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. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
BEGIN_COMMIT_OVERRIDE
feat(firestore): Added support for window functions in Pipelines, with the addWindowFields stage for computing aggregates such as running totals and moving averages over partitioned and sorted frames of documents, and over() for framing individual aggregates.
END_COMMIT_OVERRIDE