summaryrefslogtreecommitdiff
path: root/src/mongo/db/exec
diff options
context:
space:
mode:
authorSvilen Mihaylov <svilen.mihaylov@mongodb.com>2022-02-22 14:47:16 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-02-22 15:27:07 +0000
commitddb3c544036eccb70841c50490d8dfc0eaba1c25 (patch)
treed9823f1e64efebc26df38765b305b2c68766374c /src/mongo/db/exec
parenta0eb65c457a250baada836c0b6165e93449cd079 (diff)
downloadmongo-ddb3c544036eccb70841c50490d8dfc0eaba1c25.tar.gz
SERVER-63846 Lowering of HashJoinNode: switch direction of inner and outer side for hash join stage
Diffstat (limited to 'src/mongo/db/exec')
-rw-r--r--src/mongo/db/exec/sbe/abt/abt_lower.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/mongo/db/exec/sbe/abt/abt_lower.cpp b/src/mongo/db/exec/sbe/abt/abt_lower.cpp
index a82631c6aba..af3a763f7e3 100644
--- a/src/mongo/db/exec/sbe/abt/abt_lower.cpp
+++ b/src/mongo/db/exec/sbe/abt/abt_lower.cpp
@@ -639,8 +639,11 @@ std::unique_ptr<sbe::PlanStage> SBENodeLowering::walk(const HashJoinNode& n,
const ABT& leftChild,
const ABT& rightChild,
const ABT& refs) {
- auto outerStage = generateInternal(leftChild);
- auto innerStage = generateInternal(rightChild);
+ // Note the inner and outer sides here are reversed. The HashJoinNode assumes the build side is
+ // the inner side while sbe hash join stage assumes the build side is the outer side.
+
+ auto innerStage = generateInternal(leftChild);
+ auto outerStage = generateInternal(rightChild);
uassert(6624228, "Only inner joins supported for now", n.getJoinType() == JoinType::Inner);
@@ -648,11 +651,11 @@ std::unique_ptr<sbe::PlanStage> SBENodeLowering::walk(const HashJoinNode& n,
const auto& rightProps = _nodeToGroupPropsMap.at(n.getRightChild().cast<Node>());
// Add RID projection only from outer side.
- auto outerKeys = convertProjectionsToSlots(n.getLeftKeys());
- auto outerProjects = convertRequiredProjectionsToSlots(
- leftProps, false /*removeRIDProjection*/, n.getLeftKeys());
- auto innerKeys = convertProjectionsToSlots(n.getRightKeys());
+ auto innerKeys = convertProjectionsToSlots(n.getLeftKeys());
auto innerProjects = convertRequiredProjectionsToSlots(
+ leftProps, false /*removeRIDProjection*/, n.getLeftKeys());
+ auto outerKeys = convertProjectionsToSlots(n.getRightKeys());
+ auto outerProjects = convertRequiredProjectionsToSlots(
rightProps, true /*removeRIDProjection*/, n.getRightKeys());
// TODO: use collator slot.