[SERVER-18759] Add $isNull aggregation expression Created: 31/May/15 Updated: 06/Dec/22 |
|
| Status: | Backlog |
| Project: | Core Server |
| Component/s: | Aggregation Framework |
| Affects Version/s: | 3.0.3 |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Matt Kalan | Assignee: | Backlog - Query Optimization |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | expression, pm1457-nominee | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Assigned Teams: |
Query Optimization
|
||||||||
| Participants: | |||||||||
| Description |
| Comments |
| Comment by Asya Kamsky [ 09/Feb/18 ] | |||||||||||||||||||
|
Never mind my previous comment, I forgot about false and 0 which are not considered "null-ish" but would return "true" here. | |||||||||||||||||||
| Comment by Asya Kamsky [ 09/Feb/18 ] | |||||||||||||||||||
|
Is there a need for $isNull expression given that it's exactly the same as $not of the same value? {$isNull:"$exp"} is true guarantees that {$not:"$exp"} is also true.
| |||||||||||||||||||
| Comment by Asya Kamsky [ 15/Jul/16 ] | |||||||||||||||||||
|
In addition, for 3.4 you will be able to use $type to determine the type of the field. I'm sure $isNull can still be useful as syntactic sugar for some expressions, but it just becomes short for
| |||||||||||||||||||
| Comment by Asya Kamsky [ 15/Jul/16 ] | |||||||||||||||||||
|
for array use case originally described, it seems $ifNull:["$possibleArray", [ ] ] should work, no?
will always succeed on array or missing or null field. | |||||||||||||||||||
| Comment by Charlie Swanson [ 04/Nov/15 ] | |||||||||||||||||||
|
Given the discussion, I have morphed this ticket into a request for an $isNull expression. Generally, accumulators (used in the $group stage, e.g. $push, $sum, $avg), are more tolerant of malformed inputs, whereas expressions (used in a couple places, most commonly in $project, e.g. $concat, $add, $isArray) tend to error on malformed inputs. My understanding is that this will solve all issues, and avoid weird behavior of $size. Let me know if I missed anything. | |||||||||||||||||||
| Comment by Asya Kamsky [ 15/Jul/15 ] | |||||||||||||||||||
|
$size probably should continue behaving as it currently does, but it would be nice to have an $isNull test to go with $isArray to allow projecting size of 0 or 1 for non-arrays depending on whether there's a value there or not. |