diff options
author | Justin Seyster <justin.seyster@mongodb.com> | 2017-09-28 21:54:20 -0400 |
---|---|---|
committer | Justin Seyster <justin.seyster@mongodb.com> | 2017-09-28 21:54:20 -0400 |
commit | e3bb43cfa8ac0d04ba28ffd3b09a53785feabb31 (patch) | |
tree | ec22edf29d746877baa697f80bc10d0b40ebb616 /src/mongo/db/pipeline/document_source_lookup_test.cpp | |
parent | 3cf4e0593c394dd7eb45d8000d76b5dc73a3f425 (diff) | |
download | mongo-e3bb43cfa8ac0d04ba28ffd3b09a53785feabb31.tar.gz |
Revert "SERVER-30991 Introduce MatchExpression::optimize()."
This reverts commit 3cf4e0593c394dd7eb45d8000d76b5dc73a3f425.
Reverting because of a Clang compile error.
Diffstat (limited to 'src/mongo/db/pipeline/document_source_lookup_test.cpp')
-rw-r--r-- | src/mongo/db/pipeline/document_source_lookup_test.cpp | 42 |
1 files changed, 1 insertions, 41 deletions
diff --git a/src/mongo/db/pipeline/document_source_lookup_test.cpp b/src/mongo/db/pipeline/document_source_lookup_test.cpp index 66931114dbe..03ea80c5d7d 100644 --- a/src/mongo/db/pipeline/document_source_lookup_test.cpp +++ b/src/mongo/db/pipeline/document_source_lookup_test.cpp @@ -678,10 +678,7 @@ TEST_F(DocumentSourceLookUpTest, auto subPipeline = lookupStage->getSubPipeline_forTest(DOC("_id" << 5)); ASSERT(subPipeline); - // TODO: The '$$var1' in this expression actually gets optimized to a constant expression with - // value 5, but the explain output does not reflect that change. SERVER-31292 will make that - // optimization visible here, so we will need to replace '$$var1' with a $const expression for - // this test to pass. + // TODO SERVER-30991: $match within $facet should optimize to $const. auto expectedPipe = fromjson(str::stream() << "[{mock: {}}, {$match: {x:1}}, {$sort: {sortKey: {x: 1}}}, " << sequentialCacheStageObj() @@ -691,43 +688,6 @@ TEST_F(DocumentSourceLookUpTest, ASSERT_VALUE_EQ(Value(subPipeline->writeExplainOps(kExplain)), Value(BSONArray(expectedPipe))); } -TEST_F(DocumentSourceLookUpTest, ExprEmbeddedInMatchExpressionShouldBeOptimized) { - auto expCtx = getExpCtx(); - NamespaceString fromNs("test", "coll"); - expCtx->setResolvedNamespace(fromNs, {fromNs, std::vector<BSONObj>{}}); - - // This pipeline includes a $match stage that itself includes a $expr expression. - auto docSource = DocumentSourceLookUp::createFromBson( - fromjson("{$lookup: {let: {var1: '$_id'}, pipeline: [{$match: {$expr: {$eq: " - "['$_id','$$var1']}}}], from: 'coll', as: 'as'}}") - .firstElement(), - expCtx); - - auto lookupStage = static_cast<DocumentSourceLookUp*>(docSource.get()); - ASSERT(lookupStage); - - lookupStage->injectMongodInterface( - std::shared_ptr<MockMongodInterface>(new MockMongodInterface({}))); - - auto subPipeline = lookupStage->getSubPipeline_forTest(DOC("_id" << 5)); - ASSERT(subPipeline); - - auto sources = subPipeline->getSources(); - ASSERT_GTE(sources.size(), 2u); - - // The first source is our mock data source, and the second should be the $match expression. - auto secondSource = *(++sources.begin()); - auto& matchSource = dynamic_cast<const DocumentSourceMatch&>(*secondSource); - - // Ensure that the '$$var' in the embedded expression got optimized to ExpressionConstant. - BSONObjBuilder builder; - matchSource.getMatchExpression()->serialize(&builder); - auto serializedMatch = builder.obj(); - auto expectedMatch = fromjson("{$expr: {$eq: ['$_id', {$const: 5}]}}"); - - ASSERT_VALUE_EQ(Value(serializedMatch), Value(expectedMatch)); -} - TEST_F(DocumentSourceLookUpTest, ShouldIgnoreLocalVariablesShadowingLetVariablesWhenFindingNonCorrelatedPrefix) { auto expCtx = getExpCtx(); |