Skip to content

Commit 133da9f

Browse files
authored
Merge pull request #2357 from PanternBao/impove-er-11
atk-1489:improve er left join global
2 parents ff2ccd2 + bf130c4 commit 133da9f

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

dble_checkstyle_suppression.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@
2323
<suppress checks=".*" files="BTraceCostTime.java"/>
2424
<suppress checks="CyclomaticComplexity" files="CreateTableParserImp.java"/>
2525
<suppress checks="CyclomaticComplexity" files="XMLSchemaLoader.java"/>
26+
<suppress checks="CyclomaticComplexity" files="GlobalTableProcessor.java"/>
2627

2728
</suppressions>

src/main/java/com/actiontech/dble/plan/optimizer/ERJoinChooser.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
import com.actiontech.dble.DbleServer;
99
import com.actiontech.dble.config.model.ERTable;
1010
import com.actiontech.dble.plan.NamedField;
11-
import com.actiontech.dble.plan.node.PlanNode;
1211
import com.actiontech.dble.plan.common.item.Item;
1312
import com.actiontech.dble.plan.common.item.ItemField;
1413
import com.actiontech.dble.plan.common.item.function.ItemFunc;
1514
import com.actiontech.dble.plan.common.item.function.operator.cmpfunc.ItemFuncEqual;
1615
import com.actiontech.dble.plan.node.JoinNode;
16+
import com.actiontech.dble.plan.node.PlanNode;
1717
import com.actiontech.dble.plan.node.TableNode;
1818
import com.actiontech.dble.plan.util.FilterUtils;
1919
import com.actiontech.dble.plan.util.PlanUtil;
@@ -77,7 +77,7 @@ public JoinNode optimize() {
7777
* left join's ER is different from inner join's
7878
* ex:t1,t2 ,if t1 left join t2 on
7979
* t1.id=t2.id can be pushed
80-
* < we cna't change left join's structure>
80+
* < we can't change left join's structure>
8181
*
8282
* @return
8383
*/
@@ -130,7 +130,7 @@ else if (!PlanUtil.isERNode(child) && child.type() != PlanNode.PlanNodeType.TABL
130130
/* ------------------- left join optimizer end -------------------- */
131131

132132
/**
133-
* inner join's ER, rebuild inner joi's unit
133+
* inner join's ER, rebuild inner join's unit
134134
*
135135
* @return
136136
*/
@@ -390,7 +390,8 @@ private void initInnerJoinUnits(JoinNode node) {
390390
private boolean isUnit(PlanNode node) {
391391
if (isGlobalTree(node))
392392
return true;
393-
else return node.type() != PlanNode.PlanNodeType.JOIN || node.isWithSubQuery() || !((JoinNode) node).isInnerJoin();
393+
else
394+
return node.type() != PlanNode.PlanNodeType.JOIN || node.isWithSubQuery() || !((JoinNode) node).isInnerJoin();
394395
}
395396

396397
/**

src/main/java/com/actiontech/dble/plan/optimizer/GlobalTableProcessor.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ private static boolean initGlobalStatus(PlanNode tn) {
4747
if (PlanUtil.isERNode(tn)) {
4848
// treat er join as an un global table
4949
tn.setUnGlobalTableCount(1);
50-
Set<String> newSet = new HashSet<>();
51-
newSet.addAll(tn.getReferedTableNodes().get(0).getNoshardNode());
50+
Set<String> newSet = new HashSet<>(tn.getReferedTableNodes().get(0).getNoshardNode());
5251
tn.setNoshardNode(newSet);
5352
} else {
5453
int unGlobalCount = calcUnGlobalCount(tn);
@@ -76,7 +75,9 @@ private static boolean initGlobalStatus(PlanNode tn) {
7675
if (left.getUnGlobalTableCount() == 0) { // left node is global,left join will not push down
7776
tn.setNoshardNode(null);
7877
status = false;
79-
} else if (left.type() == PlanNode.PlanNodeType.TABLE || PlanUtil.isERNode(left)) {
78+
} else if (left.type() == PlanNode.PlanNodeType.TABLE ||
79+
PlanUtil.isERNode(left) ||
80+
left.getNoshardNode() != null && left.getNoshardNode().size() > 0) {
8081
if (!isGlobalTableBigEnough(jn)) {
8182
tn.setNoshardNode(null);
8283
status = false;

0 commit comments

Comments
 (0)