Skip to content

Add support for $setWindowFields aggregation stage. #3739

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

christophstrobl
Copy link
Member

Add a SetWindowFieldsOperation to the aggregation framework.

The builder API allows fluent declaration of the aggregation stage as shown in the sample below.

SetWindowFieldsOperation.builder()
	.partitionByField("state") //  partitionBy: "$state",
	.sortBy(Sort.by(Direction.ASC, "date")) // sortBy: { orderDate: 1 },
	.output(AccumulatorOperators.valueOf("qty").sum())
	.within(Windows.documents().fromUnbounded().toCurrent().build())
	.as("cumulativeQuantityForState") // cumulativeQuantityForState: { $sum: "$quantity", window: { documents: [ "unbounded", "current" ] } }
	.build();

Add a SetWindowFieldsOperation to the aggregation framework.

The builder API allows fluent declaration of the aggregation stage as shown in the sample below.

SetWindowFieldsOperation.builder()
	.partitionByField("state")
	.sortBy(Sort.by(Direction.ASC, "date"))
	.output(AccumulatorOperators.valueOf("qty").sum())
	.within(Windows.documents().fromUnbounded().toCurrent().build())
	.as("cumulativeQuantityForState")
	.build();
@christophstrobl christophstrobl linked an issue Jul 22, 2021 that may be closed by this pull request
@mp911de mp911de self-assigned this Aug 23, 2021
mp911de pushed a commit that referenced this pull request Aug 23, 2021
Add a SetWindowFieldsOperation to the aggregation framework.

The builder API allows fluent declaration of the aggregation stage as shown in the sample below.

SetWindowFieldsOperation.builder()
	.partitionByField("state")
	.sortBy(Sort.by(Direction.ASC, "date"))
	.output(AccumulatorOperators.valueOf("qty").sum())
	.within(Windows.documents().fromUnbounded().toCurrent().build())
	.as("cumulativeQuantityForState")
	.build();

Closes #3711
Original pull request: #3739.
mp911de added a commit that referenced this pull request Aug 23, 2021
Update javadoc and add assertions.

See #3711
Original pull request: #3739.
@mp911de mp911de added the type: enhancement A general enhancement label Aug 23, 2021
@mp911de mp911de added this to the 3.3 M3 (2021.1.0) milestone Aug 23, 2021
@mp911de
Copy link
Member

mp911de commented Aug 23, 2021

That's merged and polished now.

@mp911de mp911de closed this Aug 23, 2021
@mp911de mp911de deleted the issue/3711 branch August 23, 2021 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for $setWindowFields aggregation stage.
2 participants