[SERVER-36318] Add ability to extract dotted path unique key from a nested array Created: 26/Jul/18  Updated: 06/Dec/22  Resolved: 27/Jul/18

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Nicholas Zolnierz Assignee: Backlog - Query Team (Inactive)
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-35896 Support "replaceDocuments" mode in $out Closed
Related
is related to SERVER-36047 (Sharded target collection) Enforce e... Closed
Assigned Teams:
Query
Participants:

 Description   

For input document

{a: [{b: 1}]}

and a uniqueKey defined as "a.b", $out will fail to extract the key when using this method.



 Comments   
Comment by Kyle Suarez [ 27/Jul/18 ]

I'm removing this as part of the Improved $out project, though I did add text to the technical design that we will reject a document at execution time if any component of the unique key has an array traversal when extracting it.

Comment by Kyle Suarez [ 27/Jul/18 ]

Oh, I suppose that's a good point; users could transform the documents to collapse the arrays. Let's not make any changes to SERVER-36047, then.

Comment by Nicholas Zolnierz [ 27/Jul/18 ]

kyle.suarez hmm that's a good question. It seems unfortunate if $out fails only because you have an existing unique multikey index on the output collection (even if the docs in the pipeline don't contain arrays).

Comment by Kyle Suarez [ 27/Jul/18 ]

nicholas.zolnierz, I think that means we should also update SERVER-36047 to not consider a unique index if there are multikey paths at or before any one of the fields that make up the uniqueKey, right? Anything else I'm missing?

CC asya

Comment by Nicholas Zolnierz [ 26/Jul/18 ]

david.storch, makes sense. It fails somewhat unintentionally right now, so we'd have to be careful if the underlying implementation changes behavior (I think it was getNestedField() that doesn't traverse arrays).

Comment by David Storch [ 26/Jul/18 ]

nicholas.zolnierz charlie.swanson@mongodb.com, per in-person discussion, I think this ticket should be closed as "Won't Fix". It seems correct to prevent the uniqueKey index from ever being multikey. (This includes any empty arrays or singleton arrays as uniqueKey values. It also includes arrays with the same key repeated multiple times, like {a: [3, 3, 3]} with uniqueKey {a: 1}.) If we are already failing with a clear error message, then I don't think there's any more work to do here.

CC kyle.suarez

Generated at Thu Feb 08 04:42:45 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.