| 24 | } |
| 25 | |
| 26 | void JoinOperationHintsVisitor::visitJoinNode(JoinNode & node, Void & v) |
| 27 | { |
| 28 | visitPlanNode(node, v); |
| 29 | |
| 30 | TableScanHintVisitor visitor; |
| 31 | TableScanContext left_scan_context; |
| 32 | TableScanContext right_scan_context; |
| 33 | |
| 34 | VisitorUtil::accept(node.getChildren()[0], visitor, left_scan_context); |
| 35 | VisitorUtil::accept(node.getChildren()[1], visitor, right_scan_context); |
| 36 | |
| 37 | if (left_scan_context.hint_list.empty() && right_scan_context.hint_list.empty()) |
| 38 | return; |
| 39 | |
| 40 | PlanHintPtr left_hint; |
| 41 | // If there are multiple JOIN_OPERATION hints, only the first one needs to be considered |
| 42 | for (auto & hint : left_scan_context.hint_list) |
| 43 | { |
| 44 | if (hint->getType() == HintCategory::DISTRIBUTION_TYPE) |
| 45 | { |
| 46 | left_hint = hint; |
| 47 | break; |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | PlanHintPtr right_hint; |
| 52 | // If there are multiple JOIN_OPERATION hints, only the first one needs to be considered |
| 53 | for (auto & hint : right_scan_context.hint_list) |
| 54 | { |
| 55 | if (hint->getType() == HintCategory::DISTRIBUTION_TYPE) |
| 56 | { |
| 57 | right_hint = hint; |
| 58 | break; |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | if (left_hint == nullptr && right_hint == nullptr) |
| 63 | return ; |
| 64 | |
| 65 | const auto & step = *node.getStep(); |
| 66 | if (step.mustRepartition()) |
| 67 | return; |
| 68 | |
| 69 | if (step.mustReplicate()) |
| 70 | return; |
| 71 | |
| 72 | auto left_broadcast_hint = std::dynamic_pointer_cast<BroadcastJoin>(left_hint); |
| 73 | auto right_broadcast_hint = std::dynamic_pointer_cast<BroadcastJoin>(right_hint); |
| 74 | auto left_repartition_hint = std::dynamic_pointer_cast<RepartitionJoin>(left_hint); |
| 75 | auto right_repartition_hint = std::dynamic_pointer_cast<RepartitionJoin>(right_hint); |
| 76 | |
| 77 | // If the nodes on the left and right have different types of hints return; |
| 78 | if ((left_broadcast_hint && right_broadcast_hint) |
| 79 | || (left_repartition_hint && right_broadcast_hint) |
| 80 | || (right_broadcast_hint && right_repartition_hint)) |
| 81 | return; |
| 82 | |
| 83 | if (left_broadcast_hint && supportSwap(step)) |
nothing calls this directly
no test coverage detected