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 recursive operator calls for $sum aggregation accumulator #3116

Merged
merged 18 commits into from
Jul 31, 2023
Prev Previous commit
Next Next commit
wip
  • Loading branch information
noisersup committed Jul 27, 2023
commit 13e4f6d4e55fc137dd3b2827f3abf39d49b9e159
11 changes: 0 additions & 11 deletions integration/aggregate_documents_compat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1099,17 +1099,6 @@ func TestAggregateCompatGroupSum(t *testing.T) {
bson.D{{"$sort", bson.D{{"_id", -1}}}},
},
},
//"RecursiveOperatorError": {
// pipeline: bson.A{
// bson.D{{"$sort", bson.D{{"_id", 1}}}},
// bson.D{{"$group", bson.D{
// {"_id", "$_id"},
// // first $sum is accumulator operator, second $sum is operator
// {"sum", bson.D{{"$sum", bson.D{{"$sum", "$v"}}}}},
// }}},
// bson.D{{"$sort", bson.D{{"_id", -1}}}},
// },
//},
"RecursiveInvalid": {
pipeline: bson.A{
bson.D{{"$group", bson.D{{"sum", bson.D{{"$sum", bson.D{{"v", "$v"}}}}}}}},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ func (s *sum) Accumulate(iter types.DocumentsIterator) (any, error) {
case s.operator != nil:
v, err := s.operator.Process(doc)
if err != nil {
// TODO
return nil, err
}
chilagrow marked this conversation as resolved.
Show resolved Hide resolved

Expand Down
7 changes: 1 addition & 6 deletions internal/handlers/common/aggregations/operators/operators.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,7 @@ func NewOperator(doc *types.Document) (Operator, error) {

switch {
case supported:
op, err := newOperator(doc)
if err == nil {
_, err = op.Process(nil)
}

return op, err
return newOperator(doc)

case unsupported:
return nil, newOperatorError(
Expand Down