[SERVER-68405] Constant Nothing in $group's _id expression should be converted to null in $group SBE stage builder Created: 28/Jul/22  Updated: 29/Oct/23  Resolved: 29/Jul/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 5.3.2, 6.0.0
Fix Version/s: 6.0.1, 6.1.0-rc0

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

Issue Links:
Backports
Depends
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v6.0
Sprint: QE 2022-08-08
Participants:
Linked BF Score: 135

 Description   

> db.a.insert({_id: 1});
> db.a.explain().aggregate([{$group: {_id: "$$REMOVE", o: {$first: "$a"}}}]).queryPlanner.winningPlan.slotBasedPlan.stages;
[2] mkbson s9 [_id = s6, o = s8] true false
[2] group [s6] [s8 = first (fillEmpty (s7, null))]
[2] project [s7 = getField (s4, "a")]
[2] project [s6 = Nothing]
[1] scan s4 s5 none none none none [] @"39336b7b-b5b8-4328-8ae6-e5a7e9ce31ae" true false

project [s6 = Nothing] should be project [s6 = fillEmpty (Nothing, null)]. We can't do project [s6 = null] because EConstant does not have a method to examine its value.

This is a bug in $group SBE stage builder and so backport to v6.0 is necessary.



 Comments   
Comment by Yoon Soo Kim [ 03/Aug/22 ]

https://github.com/mongodb/mongo/commit/83aa49a574aa94a8aae095257fcc375942007dd9

Comment by Githook User [ 29/Jul/22 ]

Author:

{'name': 'Yoonsoo Kim', 'email': 'yoonsoo.kim@mongodb.com', 'username': 'yun-soo'}

Message: SERVER-68405 Convert Nothing for _id expression in $group to Null
Branch: master
https://github.com/mongodb/mongo/commit/5f9999bebae62b6ce3b7e534f32ba4803e15ff3d

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