You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2022/06/17 04:22:16 UTC
[incubator-doris] 02/04: [fix](optimizer) Fix the default join reorder algorithm (#10174)
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch dev-1.0.1
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
commit a9e7a1e2a562c0424d58d772706d7d361a003dc7
Author: Kikyou1997 <33...@users.noreply.github.com>
AuthorDate: Fri Jun 17 10:59:33 2022 +0800
[fix](optimizer) Fix the default join reorder algorithm (#10174)
Default join reorder algorithm not working for the most cases.
---
.../java/org/apache/doris/analysis/SelectStmt.java | 32 ++++++++++++----------
.../org/apache/doris/planner/QueryPlanTest.java | 1 -
2 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
index 8852c9fc61..e18f5cb11c 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
@@ -733,7 +733,7 @@ public class SelectStmt extends QueryStmt {
protected void reorderTable(Analyzer analyzer) throws AnalysisException {
List<Pair<TableRef, Long>> candidates = Lists.newArrayList();
-
+ List<TableRef> originOrderBackUp = Lists.newArrayList(fromClause_.getTableRefs());
// New pair of table ref and row count
for (TableRef tblRef : fromClause_) {
if (tblRef.getJoinOp() != JoinOperator.INNER_JOIN || tblRef.hasJoinHints()) {
@@ -771,8 +771,8 @@ public class SelectStmt extends QueryStmt {
// can not get AST only with equal join, MayBe cross join can help
fromClause_.clear();
- for (Pair<TableRef, Long> candidate : candidates) {
- fromClause_.add(candidate.first);
+ for (TableRef tableRef : originOrderBackUp) {
+ fromClause_.add(tableRef);
}
}
@@ -817,19 +817,21 @@ public class SelectStmt extends QueryStmt {
// is being added.
Preconditions.checkState(tid == candidateTableRef.getId());
List<Expr> candidateEqJoinPredicates = analyzer.getEqJoinConjunctsExcludeAuxPredicates(tid);
- List<TupleId> candidateTupleList = Lists.newArrayList();
- Expr.getIds(candidateEqJoinPredicates, candidateTupleList, null);
- int count = candidateTupleList.size();
- for (TupleId tupleId : candidateTupleList) {
- if (validTupleId.contains(tupleId) || tid == tupleId) {
- count--;
+ for (Expr candidateEqJoinPredicate : candidateEqJoinPredicates) {
+ List<TupleId> candidateTupleList = Lists.newArrayList();
+ Expr.getIds(Lists.newArrayList(candidateEqJoinPredicate), candidateTupleList, null);
+ int count = candidateTupleList.size();
+ for (TupleId tupleId : candidateTupleList) {
+ if (validTupleId.contains(tupleId) || tid.equals(tupleId)) {
+ count--;
+ }
+ }
+ if (count == 0) {
+ fromClause_.add(candidateTableRef);
+ validTupleId.add(tid);
+ tableRefMap.remove(tid);
+ break;
}
- }
-
- if (count == 0) {
- fromClause_.add(candidateTableRef);
- validTupleId.add(tid);
- tableRefMap.remove(tid);
}
}
}
diff --git a/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java b/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java
index df97fbc845..e97cc16c45 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java
@@ -2152,5 +2152,4 @@ public class QueryPlanTest {
Assert.assertFalse(explainString.contains("non-equal FULL OUTER JOIN is not supported"));
}
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org