[DOCS-15303] Investigate changes in SERVER-55112: Behaviour of distinct differs between collections and views Created: 02/May/22 Updated: 13/Nov/23 Resolved: 17/Jun/22 |
|
| Status: | Closed |
| Project: | Documentation |
| Component/s: | manual, Server |
| Affects Version/s: | None |
| Fix Version/s: | 6.1.0-rc0, 6.0.0-rc5, Server_Docs_20231030, Server_Docs_20231106, Server_Docs_20231105, Server_Docs_20231113 |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Backlog - Core Eng Program Management Team | Assignee: | Jason Price |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||
| Participants: | |||||||||||||||||
| Days since reply: | 1 year, 33 weeks, 1 day ago | ||||||||||||||||
| Epic Link: | DOCSP-21764 | ||||||||||||||||
| Story Points: | 3 | ||||||||||||||||
| Description |
|
Original Downstream Change Summary This is a minor change to the results of a distinct when run on a collection with a view, and the collection contains arrays at the field of interest. We are planning to backport this to 6.0. Description of Linked Ticket While investigating the behaviour as part of To test, I've created a collection with data and created a view based on an empty pipeline:
I've come up with the following calls to distinct:
Most of the cases look the same (except for different result ordering which we can ignore), but the last case differs:
Looking at the pipeline generated, we can see that documentArray.1.x produces three $unwind stages:
This is incorrect, as documentArray.1 should not unwind documentArray first, but rather use $arrayElemAt to. This modified aggregation pipeline produces the same result as the corresponding distinct command:
I was able to reproduce this in 4.2.12, 4.4.3, and 4.9.0-alpha4. It is likely that this also affects previous versions which I didn't have on hand to test. |
| Comments |
| Comment by Githook User [ 21/Jun/22 ] |
|
Author: {'name': 'jason-price-mongodb', 'email': '69260375+jason-price-mongodb@users.noreply.github.com', 'username': 'jason-price-mongodb'}Message: Docs-15303 distinct collections and views (#1263)
Co-authored-by: jason-price-mongodb <jshfjghsdfgjsdjh@aolsdjfhkjsdhfkjsdf.com> |
| Comment by Githook User [ 21/Jun/22 ] |
|
Author: {'name': 'jason-price-mongodb', 'email': '69260375+jason-price-mongodb@users.noreply.github.com', 'username': 'jason-price-mongodb'}Message: Docs-15303 distinct collections and views (#1263)
Co-authored-by: jason-price-mongodb <jshfjghsdfgjsdjh@aolsdjfhkjsdhfkjsdf.com> |
| Comment by Githook User [ 17/Jun/22 ] |
|
Author: {'name': 'jason-price-mongodb', 'email': '69260375+jason-price-mongodb@users.noreply.github.com', 'username': 'jason-price-mongodb'}Message: Docs-15303 distinct collections and views (#1263)
Co-authored-by: jason-price-mongodb <jshfjghsdfgjsdjh@aolsdjfhkjsdhfkjsdf.com> |
| Comment by Githook User [ 17/Jun/22 ] |
|
Author: {'name': 'jason-price-mongodb', 'email': '69260375+jason-price-mongodb@users.noreply.github.com', 'username': 'jason-price-mongodb'}Message: Docs-15303 distinct collections and views (#1263)
Co-authored-by: jason-price-mongodb <jshfjghsdfgjsdjh@aolsdjfhkjsdhfkjsdf.com> |
| Comment by Education Bot [ 04/May/22 ] |
|
Fix Version updated for upstream |
| Comment by Education Bot [ 02/May/22 ] |
|
Fix Version updated for upstream |