morningman commented on a change in pull request #3453:
URL: https://github.com/apache/incubator-doris/pull/3453#discussion_r419065058
##########
File path: fe/src/main/java/org/apache/doris/planner/SingleNodePlanner.java
##########
@@ -1347,6 +1349,45 @@ private PlanNode createScanNode(Analyzer analyzer,
TableRef tblRef, SelectStmt s
if (scanNode instanceof OlapScanNode || scanNode instanceof
EsScanNode) {
Map<String, PartitionColumnFilter> columnFilters =
Maps.newHashMap();
List<Expr> conjuncts = analyzer.getUnassignedConjuncts(scanNode);
+
+ // push down join predicate
+ List<Expr> pushDownConjuncts = Lists.newArrayList();
+ TupleId tupleId = tblRef.getId();
+ List<Expr> eqJoinPredicates = analyzer.getEqJoinConjuncts(tupleId);
+ if (eqJoinPredicates != null) {
+ // only inner and left outer join
+ if ((tblRef.getJoinOp().isInnerJoin() ||
tblRef.getJoinOp().isLeftOuterJoin())) {
+ List<Expr> allConjuncts =
analyzer.getConjuncts(analyzer.getAllTupleIds());
+ allConjuncts.removeAll(conjuncts);
+ for (Expr conjunct: allConjuncts) {
+ if (canPushDownPredicate(conjunct)) {
+ for (Expr eqJoinPredicate : eqJoinPredicates) {
+ // we can ensure slot is left node, because
NormalizeBinaryPredicatesRule
+ SlotRef otherSlot =
conjunct.getChild(0).unwrapSlotRef();
+
+ // ensure the children for eqJoinPredicate
both be SlotRef
+ if
(eqJoinPredicate.getChild(0).unwrapSlotRef() == null ||
eqJoinPredicate.getChild(1).unwrapSlotRef() == null) {
+ continue;
+ }
+
+ SlotRef leftSlot =
eqJoinPredicate.getChild(0).unwrapSlotRef();
+ SlotRef rightSlot =
eqJoinPredicate.getChild(1).unwrapSlotRef();
+
+ // example: t1.id = t2.id and t1.id = 1 =>
t2.id =1
+ if (otherSlot.isBound(leftSlot.getSlotId()) &&
rightSlot.isBound(tupleId)) {
+
pushDownConjuncts.add(rewritePredicate(analyzer, conjunct, rightSlot));
+ } else if
(otherSlot.isBound(rightSlot.getSlotId()) && leftSlot.isBound(tupleId)) {
+
pushDownConjuncts.add(rewritePredicate(analyzer, conjunct, leftSlot));
+ }
+ }
+ }
+ }
+ }
+
+ LOG.info("pushDownConjuncts: " + pushDownConjuncts);
Review comment:
```suggestion
LOG.debug("pushDownConjuncts: {}", pushDownConjuncts);
```
##########
File path: fe/src/main/java/org/apache/doris/planner/SingleNodePlanner.java
##########
@@ -72,6 +72,8 @@
import java.util.Map;
import java.util.UUID;
+import static org.apache.doris.analysis.Predicate.canPushDownPredicate;
Review comment:
Better not using static import
##########
File path: fe/src/main/java/org/apache/doris/planner/SingleNodePlanner.java
##########
@@ -1372,6 +1414,24 @@ private PlanNode createScanNode(Analyzer analyzer,
TableRef tblRef, SelectStmt s
return scanNode;
}
+ private Expr rewritePredicate(Analyzer analyzer, Expr oldPredicate, Expr
leftChild) {
Review comment:
Add comment for this method?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]