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 2020/08/02 14:05:55 UTC
[incubator-doris] branch master updated: [ColocateJoin]
ColocateJoin support table join itself (#4230) (#4231)
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
The following commit(s) were added to refs/heads/master by this push:
new 5caa347 [ColocateJoin] ColocateJoin support table join itself (#4230) (#4231)
5caa347 is described below
commit 5caa347e86e74c2ce4349d502d0539c8e89339d3
Author: HappenLee <ha...@hotmail.com>
AuthorDate: Sun Aug 2 22:05:45 2020 +0800
[ColocateJoin] ColocateJoin support table join itself (#4230) (#4231)
if left table and right table is same table, they are naturally colocate relationship.
---
.../apache/doris/planner/DistributedPlanner.java | 28 ++++++++++++----------
.../org/apache/doris/planner/QueryPlanTest.java | 7 ++++++
2 files changed, 23 insertions(+), 12 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/DistributedPlanner.java b/fe/fe-core/src/main/java/org/apache/doris/planner/DistributedPlanner.java
index 351a7cf..429076f 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/DistributedPlanner.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/DistributedPlanner.java
@@ -494,19 +494,23 @@ public class DistributedPlanner {
OlapTable leftTable = ((OlapScanNode) leftRoot).getOlapTable();
OlapTable rightTable = ((OlapScanNode) rightRoot).getOlapTable();
- ColocateTableIndex colocateIndex = Catalog.getCurrentColocateIndex();
-
- //1 the table must be colocate
- if (!colocateIndex.isSameGroup(leftTable.getId(), rightTable.getId())) {
- cannotReason.add("table not in same group");
- return false;
- }
+ // if left table and right table is same table, they are naturally colocate relationship
+ // no need to check colocate group
+ if (leftTable.getId() != rightTable.getId()) {
+ ColocateTableIndex colocateIndex = Catalog.getCurrentColocateIndex();
+
+ //1 the table must be colocate
+ if (!colocateIndex.isSameGroup(leftTable.getId(), rightTable.getId())) {
+ cannotReason.add("table not in the same group");
+ return false;
+ }
- //2 the colocate group must be stable
- GroupId groupId = colocateIndex.getGroup(leftTable.getId());
- if (colocateIndex.isGroupUnstable(groupId)) {
- cannotReason.add("group is not stable");
- return false;
+ //2 the colocate group must be stable
+ GroupId groupId = colocateIndex.getGroup(leftTable.getId());
+ if (colocateIndex.isGroupUnstable(groupId)) {
+ cannotReason.add("group is not stable");
+ return false;
+ }
}
DistributionInfo leftDistribution = leftTable.getDefaultDistributionInfo();
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 0134de9..57ebc3c 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
@@ -896,6 +896,13 @@ public class QueryPlanTest {
}
@Test
+ public void testSelfColocateJoin() throws Exception {
+ String queryStr = "explain select * from test.jointest t1, test.jointest t2 where t1.k1 = t2.k1";
+ String explainString = UtFrameUtils.getSQLPlanOrErrorMsg(connectContext, queryStr);
+ Assert.assertTrue(explainString.contains("colocate: true"));
+ }
+
+ @Test
public void testJoinWithMysqlTable() throws Exception {
connectContext.setDatabase("default_cluster:test");
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org