-
Type: Bug
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Aggregation Framework
-
Query Optimization
-
ALL
-
While working on SERVER-41992, which found that $setIntersection was not commutative on null and empty inputs, it became apparent that $setIntersection was also not commutative on null and invalid inputs. If a null input came first, the operation would return null but exit cleanly; if an invalid input came first, the operation would throw. We also noticed that $setIntersection is far from the only agg operator with this problem: see for example $add or $multiply
This seemed problematic because it means that, in an operation we report is commutative, the user might have their aggregation pipeline exit cleanly, or might have it fail due to an exception, depending only on the order of arguments. Even on non-commutative operations, this behavior might be confusing to users; it masks certain instances of invalid input depending on if an argument before the invalid input is null. It also is confusing as a general inconsistency: should users expect all agg operators that are passed anything null to return null, even if other input is invalid, or should they always throw when any input is invalid?