Skip to content

Commit

Permalink
flatten mark join probe keys
Browse files Browse the repository at this point in the history
  • Loading branch information
guodong authored and guodong committed Feb 2, 2023
1 parent 7804a70 commit 46b85f6
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/planner/join_order_enumerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,11 +657,18 @@ void JoinOrderEnumerator::appendMarkJoin(const expression_vector& joinNodeIDs,
LogicalPlan& buildPlan) {
// Apply flattening all but one on join nodes of both probe and build side.
unordered_set<uint32_t> joinNodeGroupsPosInProbeSide, joinNodeGroupsPosInBuildSide;
auto needFlattenProbeJoinKey = false;
needFlattenProbeJoinKey |= joinNodeIDs.size() > 1;
needFlattenProbeJoinKey |= !isJoinKeyUniqueOnBuildSide(*joinNodeIDs[0], buildPlan);
for (auto& joinNodeID : joinNodeIDs) {
joinNodeGroupsPosInProbeSide.insert(probePlan.getSchema()->getGroupPos(*joinNodeID));
auto probeKeyGroupPos = probePlan.getSchema()->getGroupPos(*joinNodeID);
if(needFlattenProbeJoinKey){
QueryPlanner::appendFlattenIfNecessary(probeKeyGroupPos, probePlan);
}
joinNodeGroupsPosInProbeSide.insert(probeKeyGroupPos);
joinNodeGroupsPosInBuildSide.insert(buildPlan.getSchema()->getGroupPos(*joinNodeID));
}
auto markGroupPos = QueryPlanner::appendFlattensButOne(joinNodeGroupsPosInProbeSide, probePlan);
auto markGroupPos = *joinNodeGroupsPosInProbeSide.begin();
QueryPlanner::appendFlattensButOne(joinNodeGroupsPosInBuildSide, buildPlan);
probePlan.increaseCost(probePlan.getCardinality() + buildPlan.getCardinality());
auto hashJoin = make_shared<LogicalHashJoin>(joinNodeIDs, mark, markGroupPos, isProbeAcc,
Expand Down

0 comments on commit 46b85f6

Please sign in to comment.