[SERVER-84159] Variadic expressions have inconsistent query shapes Created: 13/Dec/23  Updated: 03/Jan/24  Resolved: 03/Jan/24

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

Type: Bug Priority: Major - P3
Reporter: Alyssa Clark Assignee: Alyssa Clark
Resolution: Fixed Votes: 0
Labels: flag-for-2885-backport
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-85096 TRACKING: M3 Correctness Tickets Closed
Related
Assigned Teams:
Query Integration
Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:
Linked BF Score: 18

 Description   

We noticed some interesting behavior for query shapes with variadic expressions (e.g. $multiply, $sum, etc). Here are some contrasting examples:

db.c.aggregate([{$group: {_id: {$multiply: [1, 2, {$const: 3}]}}}]) 

is simplified to

{"$group": {"_id": {"$multiply": "?array<?number>"}}} 

while 

db.c.aggregate([{$group: {_id: {$multiply: [1, {$const: 1}, {$expr: {$sum: [1]}}]}}}]) 

is generally preserved as

{"$group": {"_id": {"$multiply": ["?number", "?number", "$myField", {"$sum": "?array<?number>"}]}}} 

It's not clear what the desirable behavior here (there's a tradeoff between a possibly high cardinality of query shapes vs losing details of the user's original query), but it seems like the behavior between these two cases should not be so different.



 Comments   
Comment by Githook User [ 03/Jan/24 ]

Author:

{'name': 'Alyssa Wagenmaker', 'email': 'alyssa.clark@mongodb.com', 'username': 'awagenmaker'}

Message: SERVER-84159 Don't wrap expression constant representative values in $const (#17672)

GitOrigin-RevId: 44bf6f08f6749ad58424913f4acea85b66739672
Branch: master
https://github.com/mongodb/mongo/commit/ff671fa04cd78381f7dd24ccacf7ae801059575a

Comment by Charlie Swanson [ 20/Dec/23 ]

Punting this out of PM-2885 and leaving assigned to alyssa.clark@mongodb.com to resolve. We are closing the epic since all customer-focused work is complete.

Generated at Thu Feb 08 06:54:13 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.