Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Colocate plan][Step1] Colocate join covers more situations #5521

Merged
merged 6 commits into from
Apr 11, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Changed
  • Loading branch information
EmmyMiao87 committed Apr 8, 2021
commit a98b6a890a15ae096d1fbb053dacb9d6609b54fe
Original file line number Diff line number Diff line change
Expand Up @@ -543,10 +543,8 @@ private OlapScanNode genSrcScanNode(Expr expr, PlanFragment planFragment, List<S
}
}

private boolean dataDistributionMatchEqPredicate(Map<Pair<OlapScanNode, OlapScanNode>, List<BinaryPredicate>> scanNodeWithJoinConjuncts,
List<String> cannotReason) {
// If left table and right table is same table and they select same single partition or no partition
// they are naturally colocate relationship no need to check colocate group
private boolean dataDistributionMatchEqPredicate(Map<Pair<OlapScanNode, OlapScanNode>,
List<BinaryPredicate>> scanNodeWithJoinConjuncts, List<String> cannotReason) {
for (Map.Entry<Pair<OlapScanNode, OlapScanNode>, List<BinaryPredicate>> entry : scanNodeWithJoinConjuncts.entrySet()) {
OlapScanNode leftScanNode = entry.getKey().first;
OlapScanNode rightScanNode = entry.getKey().second;
Expand All @@ -571,8 +569,8 @@ private boolean dataDistributionMatchEqPredicate(List<BinaryPredicate> eqJoinPre
// they are naturally colocate relationship no need to check colocate group
Collection<Long> leftPartitions = leftRoot.getSelectedPartitionIds();
Collection<Long> rightPartitions = rightRoot.getSelectedPartitionIds();
boolean noNeedCheckColocateGroup = (leftTable.getId() == rightTable.getId()) && (leftPartitions.equals(rightPartitions)) &&
(leftPartitions.size() <= 1);
boolean noNeedCheckColocateGroup = (leftTable.getId() == rightTable.getId())
&& (leftPartitions.equals(rightPartitions)) && (leftPartitions.size() <= 1);

if (!noNeedCheckColocateGroup) {
ColocateTableIndex colocateIndex = Catalog.getCurrentColocateIndex();
Expand Down
13 changes: 4 additions & 9 deletions fe/fe-core/src/main/java/org/apache/doris/planner/PlanNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -647,21 +647,16 @@ public String toString() {
}

public ScanNode getScanNodeInOneFragmentByTupleId(TupleId tupleId) {
if (this instanceof ScanNode) {
if (tupleIds.contains(tupleId)) {
return (ScanNode) this;
}
return null;
} else if (this instanceof ExchangeNode) {
return null;
} else {
if (this instanceof ScanNode && tupleIds.contains(tupleId)) {
return (ScanNode) this;
} else if (!(this instanceof ExchangeNode)) {
for (PlanNode planNode : children) {
ScanNode scanNode = planNode.getScanNodeInOneFragmentByTupleId(tupleId);
if (scanNode != null) {
return scanNode;
}
}
return null;
}
return null;
}
}