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

morrysnow 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 6dd0ca6d0b [fix](nereids) fix runtime filter on cte sender and set 
operation (#22181)
6dd0ca6d0b is described below

commit 6dd0ca6d0b92451eb0dd303e9e16ea4c4a54d1b7
Author: xzj7019 <[email protected]>
AuthorDate: Tue Jul 25 20:26:04 2023 +0800

    [fix](nereids) fix runtime filter on cte sender and set operation (#22181)
    
    Current rf pushdown framework doesn't handle cte sender right. On cte 
consumer, it just return false and this will cause the rf is generated at the 
wrong place and lead the expr_order checking failed, but actually it should be 
pushed down on the cte sender. Also, set operation pushing down is unreachable 
if the outer stmt uses the alias of set operation's output before probeSlot's 
translation. Both of the above issues will be fixed in this pr
---
 .../doris/nereids/processor/post/RuntimeFilterGenerator.java      | 1 +
 .../doris/nereids/trees/plans/physical/PhysicalCTEConsumer.java   | 7 ++++---
 .../doris/nereids/trees/plans/physical/PhysicalSetOperation.java  | 8 ++++++--
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/RuntimeFilterGenerator.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/RuntimeFilterGenerator.java
index 058755251d..d31b106cea 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/RuntimeFilterGenerator.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/RuntimeFilterGenerator.java
@@ -221,6 +221,7 @@ public class RuntimeFilterGenerator extends 
PlanPostProcessor {
         Map<NamedExpression, Pair<PhysicalRelation, Slot>> aliasTransferMap
                 = context.getRuntimeFilterContext().getAliasTransferMap();
         // change key when encounter alias.
+        // TODO: same action will be taken for set operation
         for (Expression expression : project.getProjects()) {
             if (expression.children().isEmpty()) {
                 continue;
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalCTEConsumer.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalCTEConsumer.java
index 67056b1681..2c0d9c6925 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalCTEConsumer.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalCTEConsumer.java
@@ -145,8 +145,9 @@ public class PhysicalCTEConsumer extends PhysicalRelation {
                                          AbstractPhysicalJoin builderNode,
                                          Expression src, Expression probeExpr,
                                          TRuntimeFilterType type, long 
buildSideNdv, int exprOrder) {
-        // TODO: current cte internal pushing down is too complicated and it 
is not convenient to move the logic here.
-        // will refine it in the future.
-        return false;
+        // push down rf on cte sender
+        // TODO: refactor pushing down into cte internal here
+        return super.pushDownRuntimeFilter(context, generator, builderNode,
+                src, probeExpr, type, buildSideNdv, exprOrder);
     }
 }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalSetOperation.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalSetOperation.java
index c77f4940b9..74ff26f319 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalSetOperation.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalSetOperation.java
@@ -146,7 +146,7 @@ public abstract class PhysicalSetOperation extends 
AbstractPhysicalPlan implemen
         boolean pushedDown = false;
         for (int i = 0; i < this.children().size(); i++) {
             AbstractPhysicalPlan child = (AbstractPhysicalPlan) this.child(i);
-            // TODO: replace this special logic with dynamic handling
+            // TODO: replace this special logic with dynamic handling and the 
name matching
             if (child instanceof PhysicalDistribute) {
                 child = (AbstractPhysicalPlan) child.child(0);
             }
@@ -154,7 +154,7 @@ public abstract class PhysicalSetOperation extends 
AbstractPhysicalPlan implemen
                 PhysicalProject project = (PhysicalProject) child;
                 int projIndex = -1;
                 Slot probeSlot = 
RuntimeFilterGenerator.checkTargetChild(probeExpr);
-                if 
(!RuntimeFilterGenerator.checkPushDownPreconditions(builderNode, ctx, 
probeSlot)) {
+                if (probeSlot == null) {
                     continue;
                 }
                 for (int j = 0; j < project.getProjects().size(); j++) {
@@ -171,6 +171,10 @@ public abstract class PhysicalSetOperation extends 
AbstractPhysicalPlan implemen
                 if (newProbeExpr instanceof Alias) {
                     newProbeExpr = (NamedExpression) newProbeExpr.child(0);
                 }
+                Slot newProbeSlot = 
RuntimeFilterGenerator.checkTargetChild(newProbeExpr);
+                if 
(!RuntimeFilterGenerator.checkPushDownPreconditions(builderNode, ctx, 
newProbeSlot)) {
+                    continue;
+                }
                 pushedDown |= child.pushDownRuntimeFilter(context, generator, 
builderNode, src,
                         newProbeExpr, type, buildSideNdv, exprOrder);
             }


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

Reply via email to