diff options
author | Davis Haupt <davis.haupt@mongodb.com> | 2023-01-10 21:30:58 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-01-10 22:44:35 +0000 |
commit | e0a7d670d213b1ab137a41f4f6585458353f626e (patch) | |
tree | fddc3023626485bec99f8ad4e36c584248cc2ab4 /src/mongo/db | |
parent | d169436600ae87f6bd486d2dea4c17bbaf886307 (diff) | |
download | mongo-e0a7d670d213b1ab137a41f4f6585458353f626e.tar.gz |
SERVER-72310 Add lowering unittest for MergeJoinNode
Diffstat (limited to 'src/mongo/db')
-rw-r--r-- | src/mongo/db/exec/sbe/abt/abt_lower_test.cpp | 56 | ||||
-rw-r--r-- | src/mongo/db/test_output/exec/sbe/a_b_t_plan_generation/lower_merge_join_node.txt | 293 |
2 files changed, 349 insertions, 0 deletions
diff --git a/src/mongo/db/exec/sbe/abt/abt_lower_test.cpp b/src/mongo/db/exec/sbe/abt/abt_lower_test.cpp index 235e24c70da..206a7f93502 100644 --- a/src/mongo/db/exec/sbe/abt/abt_lower_test.cpp +++ b/src/mongo/db/exec/sbe/abt/abt_lower_test.cpp @@ -426,6 +426,62 @@ TEST_F(ABTPlanGeneration, LowerLimitSkipNode) { _node(make<LimitSkipNode>(properties::LimitSkipRequirement(4, 2), _node(scanForTest())))); } +TEST_F(ABTPlanGeneration, LowerMergeJoinNode) { + GoldenTestContext ctx(&goldenTestConfig); + ctx.printTestHeader(GoldenTestContext::HeaderFormat::Text); + + std::vector<CollationOp> ops = {CollationOp::Ascending, CollationOp::Descending}; + // Run a variation for each supported collation. + for (auto& op : ops) { + auto child1 = createBindings( + {{"other_id", "proj0"}}, + _node(make<PhysicalScanNode>( + FieldProjectionMap{{}, {ProjectionName{"scan0"}}, {}}, "collName", false)), + "scan0"); + auto child2 = createBindings( + {{"id", "proj1"}}, + _node(make<PhysicalScanNode>( + FieldProjectionMap{{}, {ProjectionName{"scan1"}}, {}}, "otherColl", false)), + "scan1"); + runNodeVariation(ctx, + str::stream() << "Lower merge join with one projection (collation=" + << CollationOpEnum::toString[static_cast<int>(op)] << ")", + _node(make<MergeJoinNode>(ProjectionNameVector{ProjectionName{"proj0"}}, + ProjectionNameVector{ProjectionName{"proj1"}}, + std::vector<CollationOp>{op}, + std::move(child1), + std::move(child2)))); + } + + // Run variations with two projections and every possible combination of collation. + for (auto& op1 : ops) { + for (auto& op2 : ops) { + auto child1 = createBindings( + {{"other_id", "proj0"}, {"city", "proj2"}}, + _node(make<PhysicalScanNode>( + FieldProjectionMap{{}, {ProjectionName{"scan0"}}, {}}, "collName", false)), + "scan0"); + auto child2 = createBindings( + {{"id", "proj1"}, {"city", "proj3"}}, + _node(make<PhysicalScanNode>( + FieldProjectionMap{{}, {ProjectionName{"scan1"}}, {}}, "otherColl", false)), + "scan1"); + + runNodeVariation( + ctx, + str::stream() << "Lower merge join with two projections (collation=" + << CollationOpEnum::toString[static_cast<int>(op1)] << ", " + << CollationOpEnum::toString[static_cast<int>(op2)] << ")", + _node(make<MergeJoinNode>( + ProjectionNameVector{ProjectionName{"proj0"}, ProjectionName{"proj2"}}, + ProjectionNameVector{ProjectionName{"proj1"}, ProjectionName{"proj3"}}, + std::vector<CollationOp>{op1, op2}, + std::move(child1), + std::move(child2)))); + } + } +} + TEST_F(ABTPlanGeneration, LowerPhysicalScanNode) { GoldenTestContext ctx(&goldenTestConfig); ctx.printTestHeader(GoldenTestContext::HeaderFormat::Text); diff --git a/src/mongo/db/test_output/exec/sbe/a_b_t_plan_generation/lower_merge_join_node.txt b/src/mongo/db/test_output/exec/sbe/a_b_t_plan_generation/lower_merge_join_node.txt new file mode 100644 index 00000000000..add1bada248 --- /dev/null +++ b/src/mongo/db/test_output/exec/sbe/a_b_t_plan_generation/lower_merge_join_node.txt @@ -0,0 +1,293 @@ +# Golden test output of ABTPlanGeneration/LowerMergeJoinNode + +==== VARIATION: Lower merge join with one projection (collation=Ascending) ==== +-- INPUT: +MergeJoin [] +| | | Condition +| | | proj0 = proj1 +| | Collation +| | Ascending +| Evaluation [] +| | BindBlock: +| | [proj1] +| | FunctionCall [getField] +| | | Const ["id"] +| | Variable [scan1] +| PhysicalScan [{'<root>': scan1}, otherColl] +| BindBlock: +| [scan1] +| Source [] +Evaluation [] +| BindBlock: +| [proj0] +| FunctionCall [getField] +| | Const ["other_id"] +| Variable [scan0] +PhysicalScan [{'<root>': scan0}, collName] + BindBlock: + [scan0] + Source [] + +-- OUTPUT: +[4] mj + [asc] left [s2] [] + [1] project [s2 = getField(s1, "other_id")] + [0] scan s1 none none none none none [] @"<collUUID>" true false + right [s4] [] + [3] project [s4 = getField(s3, "id")] + [2] scan s3 none none none none none [] @"<collUUID>" true false + + +==== VARIATION: Lower merge join with one projection (collation=Descending) ==== +-- INPUT: +MergeJoin [] +| | | Condition +| | | proj0 = proj1 +| | Collation +| | Descending +| Evaluation [] +| | BindBlock: +| | [proj1] +| | FunctionCall [getField] +| | | Const ["id"] +| | Variable [scan1] +| PhysicalScan [{'<root>': scan1}, otherColl] +| BindBlock: +| [scan1] +| Source [] +Evaluation [] +| BindBlock: +| [proj0] +| FunctionCall [getField] +| | Const ["other_id"] +| Variable [scan0] +PhysicalScan [{'<root>': scan0}, collName] + BindBlock: + [scan0] + Source [] + +-- OUTPUT: +[4] mj + [desc] left [s2] [] + [1] project [s2 = getField(s1, "other_id")] + [0] scan s1 none none none none none [] @"<collUUID>" true false + right [s4] [] + [3] project [s4 = getField(s3, "id")] + [2] scan s3 none none none none none [] @"<collUUID>" true false + + +==== VARIATION: Lower merge join with two projections (collation=Ascending, Ascending) ==== +-- INPUT: +MergeJoin [] +| | | Condition +| | | proj0 = proj1 +| | | proj2 = proj3 +| | Collation +| | Ascending +| | Ascending +| Evaluation [] +| | BindBlock: +| | [proj3] +| | FunctionCall [getField] +| | | Const ["city"] +| | Variable [scan1] +| Evaluation [] +| | BindBlock: +| | [proj1] +| | FunctionCall [getField] +| | | Const ["id"] +| | Variable [scan1] +| PhysicalScan [{'<root>': scan1}, otherColl] +| BindBlock: +| [scan1] +| Source [] +Evaluation [] +| BindBlock: +| [proj2] +| FunctionCall [getField] +| | Const ["city"] +| Variable [scan0] +Evaluation [] +| BindBlock: +| [proj0] +| FunctionCall [getField] +| | Const ["other_id"] +| Variable [scan0] +PhysicalScan [{'<root>': scan0}, collName] + BindBlock: + [scan0] + Source [] + +-- OUTPUT: +[6] mj + [asc, asc] left [s2, s3] [] + [2] project [s3 = getField(s1, "city")] + [1] project [s2 = getField(s1, "other_id")] + [0] scan s1 none none none none none [] @"<collUUID>" true false + right [s5, s6] [] + [5] project [s6 = getField(s4, "city")] + [4] project [s5 = getField(s4, "id")] + [3] scan s4 none none none none none [] @"<collUUID>" true false + + +==== VARIATION: Lower merge join with two projections (collation=Ascending, Descending) ==== +-- INPUT: +MergeJoin [] +| | | Condition +| | | proj0 = proj1 +| | | proj2 = proj3 +| | Collation +| | Ascending +| | Descending +| Evaluation [] +| | BindBlock: +| | [proj3] +| | FunctionCall [getField] +| | | Const ["city"] +| | Variable [scan1] +| Evaluation [] +| | BindBlock: +| | [proj1] +| | FunctionCall [getField] +| | | Const ["id"] +| | Variable [scan1] +| PhysicalScan [{'<root>': scan1}, otherColl] +| BindBlock: +| [scan1] +| Source [] +Evaluation [] +| BindBlock: +| [proj2] +| FunctionCall [getField] +| | Const ["city"] +| Variable [scan0] +Evaluation [] +| BindBlock: +| [proj0] +| FunctionCall [getField] +| | Const ["other_id"] +| Variable [scan0] +PhysicalScan [{'<root>': scan0}, collName] + BindBlock: + [scan0] + Source [] + +-- OUTPUT: +[6] mj + [asc, desc] left [s2, s3] [] + [2] project [s3 = getField(s1, "city")] + [1] project [s2 = getField(s1, "other_id")] + [0] scan s1 none none none none none [] @"<collUUID>" true false + right [s5, s6] [] + [5] project [s6 = getField(s4, "city")] + [4] project [s5 = getField(s4, "id")] + [3] scan s4 none none none none none [] @"<collUUID>" true false + + +==== VARIATION: Lower merge join with two projections (collation=Descending, Ascending) ==== +-- INPUT: +MergeJoin [] +| | | Condition +| | | proj0 = proj1 +| | | proj2 = proj3 +| | Collation +| | Descending +| | Ascending +| Evaluation [] +| | BindBlock: +| | [proj3] +| | FunctionCall [getField] +| | | Const ["city"] +| | Variable [scan1] +| Evaluation [] +| | BindBlock: +| | [proj1] +| | FunctionCall [getField] +| | | Const ["id"] +| | Variable [scan1] +| PhysicalScan [{'<root>': scan1}, otherColl] +| BindBlock: +| [scan1] +| Source [] +Evaluation [] +| BindBlock: +| [proj2] +| FunctionCall [getField] +| | Const ["city"] +| Variable [scan0] +Evaluation [] +| BindBlock: +| [proj0] +| FunctionCall [getField] +| | Const ["other_id"] +| Variable [scan0] +PhysicalScan [{'<root>': scan0}, collName] + BindBlock: + [scan0] + Source [] + +-- OUTPUT: +[6] mj + [desc, asc] left [s2, s3] [] + [2] project [s3 = getField(s1, "city")] + [1] project [s2 = getField(s1, "other_id")] + [0] scan s1 none none none none none [] @"<collUUID>" true false + right [s5, s6] [] + [5] project [s6 = getField(s4, "city")] + [4] project [s5 = getField(s4, "id")] + [3] scan s4 none none none none none [] @"<collUUID>" true false + + +==== VARIATION: Lower merge join with two projections (collation=Descending, Descending) ==== +-- INPUT: +MergeJoin [] +| | | Condition +| | | proj0 = proj1 +| | | proj2 = proj3 +| | Collation +| | Descending +| | Descending +| Evaluation [] +| | BindBlock: +| | [proj3] +| | FunctionCall [getField] +| | | Const ["city"] +| | Variable [scan1] +| Evaluation [] +| | BindBlock: +| | [proj1] +| | FunctionCall [getField] +| | | Const ["id"] +| | Variable [scan1] +| PhysicalScan [{'<root>': scan1}, otherColl] +| BindBlock: +| [scan1] +| Source [] +Evaluation [] +| BindBlock: +| [proj2] +| FunctionCall [getField] +| | Const ["city"] +| Variable [scan0] +Evaluation [] +| BindBlock: +| [proj0] +| FunctionCall [getField] +| | Const ["other_id"] +| Variable [scan0] +PhysicalScan [{'<root>': scan0}, collName] + BindBlock: + [scan0] + Source [] + +-- OUTPUT: +[6] mj + [desc, desc] left [s2, s3] [] + [2] project [s3 = getField(s1, "city")] + [1] project [s2 = getField(s1, "other_id")] + [0] scan s1 none none none none none [] @"<collUUID>" true false + right [s5, s6] [] + [5] project [s6 = getField(s4, "city")] + [4] project [s5 = getField(s4, "id")] + [3] scan s4 none none none none none [] @"<collUUID>" true false + |