imay commented on a change in pull request #246: Colocate Join (#245)
URL: https://github.com/apache/incubator-doris/pull/246#discussion_r231441980
##########
File path: fe/src/main/java/org/apache/doris/planner/DistributedPlanner.java
##########
@@ -395,6 +414,81 @@ private PlanFragment createHashJoinFragment(HashJoinNode
node, PlanFragment righ
}
}
+ private boolean canColocateJoin(HashJoinNode node, PlanFragment
leftChildFragment, PlanFragment rightChildFragment) {
+ if (ConnectContext.get().getSessionVariable().isDisableColocateJoin())
{
+ return false;
+ }
+
+ PlanNode leftRoot = leftChildFragment.getPlanRoot();
+ PlanNode rightRoot = rightChildFragment.getPlanRoot();
+
+ //leftRoot could be ScanNode or HashJoinNode, rightRoot should be
ScanNode
+ if (leftRoot instanceof OlapScanNode && rightRoot instanceof
OlapScanNode) {
+ return canColocateJoin(node, leftRoot, rightRoot);
+ }
+
+ if (leftRoot instanceof HashJoinNode && rightRoot instanceof
OlapScanNode) {
+ while (leftRoot instanceof HashJoinNode) {
+ if (((HashJoinNode)leftRoot).isColocate()) {
+ leftRoot = leftRoot.getChild(0);
+ } else {
+ return false;
+ }
+ }
+ return canColocateJoin(node, leftRoot, rightRoot);
+ }
+
+ return false;
+ }
+
+ //the table must be colocate
+ //the colocate group must be stable
+ //the eqJoinConjuncts must contain the distributionColumns
+ private boolean canColocateJoin(HashJoinNode node, PlanNode leftRoot,
PlanNode rightRoot) {
+ OlapTable leftTable = ((OlapScanNode) leftRoot).getOlapTable();
+ OlapTable rightTable = ((OlapScanNode) rightRoot).getOlapTable();
+
+ //1 the table must be colocate
+ if (leftTable.getColocateTable() != null &&
+
leftTable.getColocateTable().equalsIgnoreCase(rightTable.getColocateTable())) {
Review comment:
```suggestion
if (leftTable.getColocateTable() == null ||
!leftTable.getColocateTable().equalsIgnoreCase(rightTable.getColocateTable())) {
return false;
}
```
I think this is better
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]