diff options
author | Charlie Swanson <charlie.swanson@mongodb.com> | 2019-02-06 12:37:43 -0500 |
---|---|---|
committer | James Wahlin <james@mongodb.com> | 2019-03-01 16:56:06 -0500 |
commit | 94b2ddce2e3a43ea94e99394336c8bd77bcefbe5 (patch) | |
tree | 693f2397888768a725095827b0b5696a409bb1e7 | |
parent | a02a0b224ffef64c82ddbb1207cc1737e269dc8f (diff) | |
download | mongo-94b2ddce2e3a43ea94e99394336c8bd77bcefbe5.tar.gz |
SERVER-39394 Traverse $lookup subpipeline for more involved collections
(cherry picked from commit 346b2980a2122f984bfa4c359468f547776caae6)
(cherry picked from commit fbd1f7e6bbb9da5c1efb3e34cb66ef07dd93290c)
-rw-r--r-- | buildscripts/resmokeconfig/suites/replica_sets_jscore_fcv34_passthrough.yml | 2 | ||||
-rw-r--r-- | jstests/core/views/views_collation.js | 68 | ||||
-rw-r--r-- | src/mongo/db/pipeline/document_source_lookup.h | 5 |
3 files changed, 75 insertions, 0 deletions
diff --git a/buildscripts/resmokeconfig/suites/replica_sets_jscore_fcv34_passthrough.yml b/buildscripts/resmokeconfig/suites/replica_sets_jscore_fcv34_passthrough.yml index 731659ee5d7..6ec4e4066ab 100644 --- a/buildscripts/resmokeconfig/suites/replica_sets_jscore_fcv34_passthrough.yml +++ b/buildscripts/resmokeconfig/suites/replica_sets_jscore_fcv34_passthrough.yml @@ -11,6 +11,8 @@ selector: - jstests/core/capped_update.js # JSON Schema is not available in featureCompatibilityVersion 3.4 - jstests/core/json_schema/*.js + # Uses $lookup pipeline syntax, which is not available in featureCompatibilityVersion 3.4 + - jstests/core/views/views_collation.js exclude_with_any_tags: - requires_fcv36 diff --git a/jstests/core/views/views_collation.js b/jstests/core/views/views_collation.js index 83f5be0a30b..428927751c8 100644 --- a/jstests/core/views/views_collation.js +++ b/jstests/core/views/views_collation.js @@ -161,6 +161,16 @@ const lookupSimpleView = { $lookup: {from: "simpleView", localField: "x", foreignField: "x", as: "result"} }; + const nestedLookupSimpleView = { + $lookup: { + from: "simpleCollection", + pipeline: [{ + $lookup: + {from: "simpleView", localField: "x", foreignField: "x", as: "inner_result"} + }], + as: "result" + } + }; const graphLookupSimpleView = { $graphLookup: { from: "simpleView", @@ -176,6 +186,8 @@ assert.commandWorked(viewsDB.runCommand( {aggregate: "simpleCollection", pipeline: [lookupSimpleView], cursor: {}})); assert.commandWorked(viewsDB.runCommand( + {aggregate: "simpleCollection", pipeline: [nestedLookupSimpleView], cursor: {}})); + assert.commandWorked(viewsDB.runCommand( {aggregate: "simpleCollection", pipeline: [graphLookupSimpleView], cursor: {}})); // You can lookup into a view with the simple collation if the operation has a matching @@ -188,6 +200,12 @@ })); assert.commandWorked(viewsDB.runCommand({ aggregate: "ukCollection", + pipeline: [nestedLookupSimpleView], + cursor: {}, + collation: {locale: "simple"} + })); + assert.commandWorked(viewsDB.runCommand({ + aggregate: "ukCollection", pipeline: [graphLookupSimpleView], cursor: {}, collation: {locale: "simple"} @@ -204,6 +222,13 @@ ErrorCodes.OptionNotSupportedOnView); assert.commandFailedWithCode(viewsDB.runCommand({ aggregate: "simpleCollection", + pipeline: [nestedLookupSimpleView], + cursor: {}, + collation: {locale: "en"} + }), + ErrorCodes.OptionNotSupportedOnView); + assert.commandFailedWithCode(viewsDB.runCommand({ + aggregate: "simpleCollection", pipeline: [graphLookupSimpleView], cursor: {}, collation: {locale: "zh"} @@ -213,6 +238,18 @@ const lookupFilView = { $lookup: {from: "filView", localField: "x", foreignField: "x", as: "result"} }; + function makeNestedLookupFilView(sourceCollName) { + return { + $lookup: { + from: sourceCollName, + pipeline: [{ + $lookup: + {from: "filView", localField: "x", foreignField: "x", as: "inner_result"} + }], + as: "result" + } + }; + } const graphLookupFilView = { $graphLookup: { from: "filView", @@ -227,6 +264,11 @@ // collation matches the collation of the view. assert.commandWorked( viewsDB.runCommand({aggregate: "filCollection", pipeline: [lookupFilView], cursor: {}})); + assert.commandWorked(viewsDB.runCommand({ + aggregate: "filCollection", + pipeline: [makeNestedLookupFilView("filCollection")], + cursor: {} + })); assert.commandWorked(viewsDB.runCommand( {aggregate: "filCollection", pipeline: [graphLookupFilView], cursor: {}})); @@ -240,6 +282,12 @@ })); assert.commandWorked(viewsDB.runCommand({ aggregate: "ukCollection", + pipeline: [makeNestedLookupFilView("ukCollection")], + cursor: {}, + collation: {locale: "fil"} + })); + assert.commandWorked(viewsDB.runCommand({ + aggregate: "ukCollection", pipeline: [graphLookupFilView], cursor: {}, collation: {locale: "fil"} @@ -250,6 +298,12 @@ assert.commandFailedWithCode( viewsDB.runCommand({aggregate: "simpleCollection", cursor: {}, pipeline: [lookupFilView]}), ErrorCodes.OptionNotSupportedOnView); + assert.commandFailedWithCode(viewsDB.runCommand({ + aggregate: "simpleCollection", + cursor: {}, + pipeline: [makeNestedLookupFilView("simpleCollation")] + }), + ErrorCodes.OptionNotSupportedOnView); assert.commandFailedWithCode( viewsDB.runCommand( {aggregate: "simpleCollection", cursor: {}, pipeline: [graphLookupFilView]}), @@ -266,6 +320,13 @@ ErrorCodes.OptionNotSupportedOnView); assert.commandFailedWithCode(viewsDB.runCommand({ aggregate: "filCollection", + pipeline: [makeNestedLookupFilView("filCollection")], + cursor: {}, + collation: {locale: "zh"} + }), + ErrorCodes.OptionNotSupportedOnView); + assert.commandFailedWithCode(viewsDB.runCommand({ + aggregate: "filCollection", pipeline: [graphLookupFilView], cursor: {}, collation: {locale: "zh"} @@ -327,6 +388,13 @@ assert.commandFailedWithCode(viewsDB.runCommand({ create: "zhView", viewOn: "simpleCollection", + pipeline: [makeNestedLookupFilView("zhView")], + collation: {locale: "zh"} + }), + ErrorCodes.OptionNotSupportedOnView); + assert.commandFailedWithCode(viewsDB.runCommand({ + create: "zhView", + viewOn: "simpleCollection", pipeline: [graphLookupSimpleView], collation: {locale: "zh"} }), diff --git a/src/mongo/db/pipeline/document_source_lookup.h b/src/mongo/db/pipeline/document_source_lookup.h index 4d865820b10..58c2ee1e431 100644 --- a/src/mongo/db/pipeline/document_source_lookup.h +++ b/src/mongo/db/pipeline/document_source_lookup.h @@ -135,6 +135,11 @@ public: void addInvolvedCollections(std::vector<NamespaceString>* collections) const final { collections->push_back(_fromNs); + if (_parsedIntrospectionPipeline) { + for (auto&& stage : _parsedIntrospectionPipeline->getSources()) { + stage->addInvolvedCollections(collections); + } + } } void doDetachFromOperationContext() final; |