Skip to content
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

Support _id aggregation operators for $group stage #3096

Merged
merged 19 commits into from
Jul 26, 2023
Prev Previous commit
Next Next commit
fix
  • Loading branch information
noisersup committed Jul 24, 2023
commit 91e489c852f4bf23cac4230962fb95fdfa9afb46
12 changes: 12 additions & 0 deletions integration/aggregate_documents_compat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,18 @@ func TestAggregateCompatGroup(t *testing.T) {
bson.D{{"$sort", bson.D{{"_id", 1}}}},
},
},
"IDSumInvalid": {
pipeline: bson.A{
bson.D{{"$group", bson.D{{"_id", bson.D{{"$sum", "$"}}}}}},
},
resultType: emptyResult,
},
"IDSumRecursiveInvalid": {
pipeline: bson.A{
bson.D{{"$group", bson.D{{"_id", bson.D{{"$sum", bson.D{{"$sum", "$"}}}}}}}},
},
resultType: emptyResult,
},
}

testAggregateStagesCompat(t, testCases)
Expand Down
4 changes: 0 additions & 4 deletions internal/handlers/common/aggregations/stages/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,6 @@ func (g *group) Process(ctx context.Context, iter types.DocumentsIterator, close
func (g *group) groupDocuments(ctx context.Context, in []*types.Document) ([]groupedDocuments, error) {
switch groupKey := g.groupExpression.(type) {
case *types.Document:
if !operators.IsOperator(groupKey) {
break
}

op, err := operators.NewOperator(groupKey)
if err != nil {
return nil, err
chilagrow marked this conversation as resolved.
Show resolved Hide resolved
Expand Down