diff options
author | Svilen Mihaylov <svilen.mihaylov@mongodb.com> | 2022-12-13 16:50:18 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-12-13 18:00:06 +0000 |
commit | 21a03e441d6c36265d0b35d2ac80a9202665262b (patch) | |
tree | cbfd58aebd68a91c78e6dbfa3df2e24c95ec58d1 /src/mongo/db/pipeline/abt/abt_translation_test.cpp | |
parent | 015adcc72b477f19c8cbd8a03b95b2a393c4b181 (diff) | |
download | mongo-21a03e441d6c36265d0b35d2ac80a9202665262b.tar.gz |
SERVER-71384 [CQF] Speed up vending of projection names
Diffstat (limited to 'src/mongo/db/pipeline/abt/abt_translation_test.cpp')
-rw-r--r-- | src/mongo/db/pipeline/abt/abt_translation_test.cpp | 71 |
1 files changed, 68 insertions, 3 deletions
diff --git a/src/mongo/db/pipeline/abt/abt_translation_test.cpp b/src/mongo/db/pipeline/abt/abt_translation_test.cpp index 8cfc46728af..fe997690751 100644 --- a/src/mongo/db/pipeline/abt/abt_translation_test.cpp +++ b/src/mongo/db/pipeline/abt/abt_translation_test.cpp @@ -205,8 +205,6 @@ TEST_F(ABTTranslationTest, SortTranslation) { testABTTranslationAndOptimization("$match sort", "[{$match: {'a': 10}}, {$sort: {'a': 1}}]"); } -} // namespace - TEST_F(ServiceContextTest, CanonicalQueryTranslation) { Metadata metadata({{"collection", createScanDef({}, {})}}); @@ -215,7 +213,7 @@ TEST_F(ServiceContextTest, CanonicalQueryTranslation) { fromjson("{find: 'collection', '$db': 'test', filter: {a: 10, b: 20, c:30}}")); auto statusWithCQ = CanonicalQuery::canonicalize(opCtx.get(), std::move(findCommand)); ASSERT_OK(statusWithCQ.getStatus()); - PrefixId prefixId; + auto prefixId = PrefixId::createForTests(); auto translation = translateCanonicalQueryToABT(metadata, *(statusWithCQ.getValue()), @@ -256,4 +254,71 @@ TEST_F(ServiceContextTest, CanonicalQueryTranslation) { translation); } +TEST_F(ServiceContextTest, NonDescriptiveNames) { + auto prefixId = PrefixId::create(false /*useDescriptiveVarNames*/); + Metadata metadata({{"collection", createScanDef({}, {})}}); + + const std::string& pipeline = "[{$group: {_id: '$a.b', s: {$sum: {$multiply: ['$b', '$c']}}}}]"; + const ProjectionName scanProjName = prefixId.getNextId("scan"); + + ABT translated = + translatePipeline(metadata, pipeline, scanProjName, "collection", prefixId, {}); + + // Observe projection names are not descriptive. They are of the form "pXXXX". + ASSERT_EXPLAIN_V2( + "Root []\n" + "| | projections: \n" + "| | p4\n" + "| RefBlock: \n" + "| Variable [p4]\n" + "Evaluation []\n" + "| BindBlock:\n" + "| [p4]\n" + "| EvalPath []\n" + "| | Const [{}]\n" + "| PathComposeM []\n" + "| | PathField [s]\n" + "| | PathConstant []\n" + "| | Variable [p2]\n" + "| PathField [_id]\n" + "| PathConstant []\n" + "| Variable [p1]\n" + "GroupBy []\n" + "| | groupings: \n" + "| | RefBlock: \n" + "| | Variable [p1]\n" + "| aggregations: \n" + "| [p2]\n" + "| FunctionCall [$sum]\n" + "| Variable [p3]\n" + "Evaluation []\n" + "| BindBlock:\n" + "| [p3]\n" + "| BinaryOp [Mult]\n" + "| | EvalPath []\n" + "| | | Variable [p0]\n" + "| | PathGet [c]\n" + "| | PathIdentity []\n" + "| EvalPath []\n" + "| | Variable [p0]\n" + "| PathGet [b]\n" + "| PathIdentity []\n" + "Evaluation []\n" + "| BindBlock:\n" + "| [p1]\n" + "| EvalPath []\n" + "| | Variable [p0]\n" + "| PathGet [a]\n" + "| PathTraverse [inf]\n" + "| PathGet [b]\n" + "| PathIdentity []\n" + "Scan [collection]\n" + " BindBlock:\n" + " [p0]\n" + " Source []\n", + translated); +} + +} // namespace + } // namespace mongo::optimizer |