[SERVER-54235] Implement $count window function desugaring Created: 03/Feb/21  Updated: 29/Oct/23  Resolved: 30/Apr/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 5.0.0-rc0

Type: Task Priority: Major - P3
Reporter: Nicholas Zolnierz Assignee: Joel Redman (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-54338 Support default expression in $shift ... Closed
Backwards Compatibility: Fully Compatible
Sprint: Query Optimization 2021-02-22, Query Optimization 2021-03-08, Query Optimization 2021-03-22, Query Optimization 2021-04-05, Query Optimization 2021-04-19, Query Optimization 2021-05-03
Participants:

 Description   

From Syntax:

$count

This is a new accumulator which returns the number of documents in the current window/partition. In $group, it is identical to {newField: {$sum: 1}} but will only be exposed as a window function. It is an error to specify an input expression to $count, but a non-default window may be specified.

{newField: {$count: {}, window: ...}}

 

 

From Technical Design Document: 

A $count window function will be desugared to a $sum with an input expression of the constant '1'. The window definition will remain the same.



 Comments   
Comment by Githook User [ 30/Apr/21 ]

Author:

{'name': 'Joel Redman', 'email': 'joel.redman@mongodb.com', 'username': 'joredman'}

Message: SERVER-54235 Desugar $count window function as {$sum : 1}
Branch: master
https://github.com/mongodb/mongo/commit/fd131cf1a817713b563bd641bbbe5371b1f4664d

Generated at Thu Feb 08 05:32:59 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.