This is an automated email from the ASF dual-hosted git repository.

englefly pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 17af099dc3 [fix](nereids)miss group id in explain plan #21402
17af099dc3 is described below

commit 17af099dc3a5a3a23dc06ef3a568db294458fa01
Author: minghong <[email protected]>
AuthorDate: Mon Jul 3 13:16:33 2023 +0800

    [fix](nereids)miss group id in explain plan #21402
    
    after we introduce "PushdownFilterThroughProject" post processor, some plan 
node missed their groupExpression (withChildren function will remove 
groupExpression).
    this is not good for debug, since it takes more time to find the owner 
group of a plan node
    This pr record the missing owner group id in plan node mutableState.
---
 .../src/main/java/org/apache/doris/nereids/memo/GroupId.java  |  2 +-
 .../src/main/java/org/apache/doris/nereids/memo/Memo.java     |  2 +-
 .../org/apache/doris/nereids/trees/plans/AbstractPlan.java    | 11 ++++++++---
 .../doris/nereids/trees/plans/physical/PhysicalHashJoin.java  |  7 ++++++-
 4 files changed, 16 insertions(+), 6 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/memo/GroupId.java 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/memo/GroupId.java
index b3870dd84a..70ba3786a1 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/memo/GroupId.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/memo/GroupId.java
@@ -44,6 +44,6 @@ public class GroupId extends Id<GroupId> {
 
     @Override
     public String toString() {
-        return "GroupId#" + id;
+        return "@" + id;
     }
 }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/memo/Memo.java 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/memo/Memo.java
index d39b92d360..bdcf98d3bf 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/memo/Memo.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/memo/Memo.java
@@ -751,7 +751,7 @@ public class Memo {
                         if (costAndGroupExpression.isPresent()) {
                             Cost cost = costAndGroupExpression.get().first;
                             GroupExpression child = 
costAndGroupExpression.get().second;
-                            builder.append("\n    " + cost.getValue() + " " + 
prop)
+                            builder.append("\n\n    " + cost.getValue() + " " 
+ prop)
                                     .append("\n     ").append(child)
                                     .append("\n     " + 
child.getInputPropertiesListOrEmpty(prop));
                         }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/AbstractPlan.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/AbstractPlan.java
index f3d545c8ea..2128827af1 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/AbstractPlan.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/AbstractPlan.java
@@ -203,9 +203,14 @@ public abstract class AbstractPlan extends 
AbstractTreeNode<Plan> implements Pla
      * @return "" if groupExpression is empty, o.w. string format of group id
      */
     public String getGroupIdAsString() {
-        String groupId = getGroupExpression().isPresent()
-                ? "#" + 
getGroupExpression().get().getOwnerGroup().getGroupId().asInt()
-                : "";
+        String groupId;
+        if (getGroupExpression().isPresent()) {
+            groupId = "@" + 
groupExpression.get().getOwnerGroup().getGroupId().asInt();
+        } else if (getMutableState("group").isPresent()) {
+            groupId = "@" + getMutableState("group").get();
+        } else {
+            groupId = "";
+        }
         return groupId;
     }
 
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalHashJoin.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalHashJoin.java
index 7a75383868..f1e4e329b8 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalHashJoin.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalHashJoin.java
@@ -158,9 +158,14 @@ public class PhysicalHashJoin<
     @Override
     public PhysicalHashJoin<Plan, Plan> withChildren(List<Plan> children) {
         Preconditions.checkArgument(children.size() == 2);
-        return new PhysicalHashJoin<>(joinType, hashJoinConjuncts, 
otherJoinConjuncts, hint, markJoinSlotReference,
+        PhysicalHashJoin newJoin = new PhysicalHashJoin<>(joinType, 
hashJoinConjuncts,
+                otherJoinConjuncts, hint, markJoinSlotReference,
                 Optional.empty(), getLogicalProperties(), physicalProperties, 
statistics,
                 children.get(0), children.get(1));
+        if (groupExpression.isPresent()) {
+            newJoin.setMutableState("group", 
groupExpression.get().getOwnerGroup().getGroupId().asInt());
+        }
+        return newJoin;
     }
 
     @Override


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to