optimize er left join global (#2334)

* optimize er left join global

* optimize er left join global

* fix checkstyle

(cherry picked from commit 2f6b3bfec1)
This commit is contained in:
Collapsar
2020-11-27 22:32:44 +08:00
committed by baofengqi
parent 0f4d5fdc22
commit 76155e308d
3 changed files with 10 additions and 7 deletions
+1 -1
View File
@@ -23,5 +23,5 @@
<suppress checks=".*" files="BTraceCostTime.java"/>
<suppress checks="CyclomaticComplexity" files="CreateTableParserImp.java"/>
<suppress checks="CyclomaticComplexity" files="XMLSchemaLoader.java"/>
<suppress checks="CyclomaticComplexity" files="GlobalTableProcessor.java"/>
</suppressions>
@@ -77,7 +77,7 @@ public class ERJoinChooser {
* left join's ER is different from inner join's
* ex:t1,t2 ,if t1 left join t2 on
* t1.id=t2.id can be pushed
* < we cna't change left join's structure>
* < we can't change left join's structure>
*
* @return
*/
@@ -107,6 +107,7 @@ public class ERJoinChooser {
return null;
else if (!PlanUtil.isERNode(child) && child.type() != PlanNode.PlanNodeType.TABLE)
return null;
if (onItem == null || !onItem.type().equals(Item.ItemType.FIELD_ITEM))
return null;
Pair<TableNode, ItemField> joinColumnInfo = PlanUtil.findColumnInTableLeaf((ItemField) onItem, joinNode);
@@ -130,7 +131,7 @@ public class ERJoinChooser {
/* ------------------- left join optimizer end -------------------- */
/**
* inner join's ER, rebuild inner joi's unit
* inner join's ER, rebuild inner join's unit
*
* @return
*/
@@ -390,7 +391,8 @@ public class ERJoinChooser {
private boolean isUnit(PlanNode node) {
if (isGlobalTree(node))
return true;
else return node.type() != PlanNode.PlanNodeType.JOIN || node.isWithSubQuery() || !((JoinNode) node).isInnerJoin();
else
return node.type() != PlanNode.PlanNodeType.JOIN || node.isWithSubQuery() || !((JoinNode) node).isInnerJoin();
}
/**
@@ -47,8 +47,7 @@ public final class GlobalTableProcessor {
if (PlanUtil.isERNode(tn)) {
// treat er join as an un global table
tn.setUnGlobalTableCount(1);
Set<String> newSet = new HashSet<>();
newSet.addAll(tn.getReferedTableNodes().get(0).getNoshardNode());
Set<String> newSet = new HashSet<>(tn.getReferedTableNodes().get(0).getNoshardNode());
tn.setNoshardNode(newSet);
} else {
int unGlobalCount = calcUnGlobalCount(tn);
@@ -76,7 +75,9 @@ public final class GlobalTableProcessor {
if (left.getUnGlobalTableCount() == 0) { // left node is global,left join will not push down
tn.setNoshardNode(null);
status = false;
} else if (left.type() == PlanNode.PlanNodeType.TABLE || PlanUtil.isERNode(left)) {
} else if (left.type() == PlanNode.PlanNodeType.TABLE ||
PlanUtil.isERNode(left) ||
left.getNoshardNode() != null && left.getNoshardNode().size() > 0) {
if (!isGlobalTableBigEnough(jn)) {
tn.setNoshardNode(null);
status = false;