[SERVER-60762] $setWindowFields partitionBy an array should consistently error Created: 15/Oct/21  Updated: 29/Oct/23  Resolved: 22/Oct/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 5.2.0, 5.1.0-rc3, 5.0.5

Type: Bug Priority: Major - P3
Reporter: David Percy Assignee: David Percy
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Backwards Compatibility: Minor Change
Operating System: ALL
Backport Requested:
v5.1, v5.0
Sprint: QO 2021-11-01
Participants:
Linked BF Score: 175

 Description   

$setWindowFields raises an error if the partitionBy expression ever evaluates to an array. (We added this restriction to allow $sort to handle most of the partitioning.)

But during parsing, if the partitionBy expression optimizes to a constant, we remove it. (Partitioning by a constant is equivalent to not doing any partitioning.) We do this even if it's a constant array, which hides the error. This is misleading: we say partitionBy can't be an array, but then examples like 'partitionBy: [1, 2, 3]' don't raise an error.



 Comments   
Comment by Githook User [ 04/Nov/21 ]

Author:

{'name': 'David Percy', 'email': 'david.percy@mongodb.com', 'username': 'dpercy'}

Message: SERVER-60762 Error when partitionBy is a constant array
Branch: v5.0
https://github.com/mongodb/mongo/commit/5d2260590a33e8285f29f0cda55d0e73abf89202

Comment by Githook User [ 29/Oct/21 ]

Author:

{'name': 'David Percy', 'email': 'david.percy@mongodb.com', 'username': 'dpercy'}

Message: SERVER-60762 Error when partitionBy is a constant array
Branch: v5.1
https://github.com/mongodb/mongo/commit/73b81b958fc245dcd72b55830868c63f07993b73

Comment by Githook User [ 22/Oct/21 ]

Author:

{'name': 'David Percy', 'email': 'david.percy@mongodb.com', 'username': 'dpercy'}

Message: SERVER-60762 Error when partitionBy is a constant array
Branch: master
https://github.com/mongodb/mongo/commit/8c36f85cd9a697e7419ea56ff80fa2a6449bcaf8

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