github-actions[bot] commented on code in PR #62383:
URL: https://github.com/apache/doris/pull/62383#discussion_r3108095411


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/RuntimeFilterPushDownVisitor.java:
##########
@@ -259,61 +220,49 @@ public Boolean visitPhysicalHashJoin(PhysicalHashJoin<? 
extends Plan, ? extends
                 +---->t2
              RF(t1.A <=> t2.A) cannot be pushed down through left outer join
              */
-            EqualPredicate equal = (EqualPredicate) 
ctx.builderNode.getHashJoinConjuncts().get(ctx.exprOrder);
+            EqualPredicate equal = (EqualPredicate) ((AbstractPhysicalJoin<?, 
?>) ctx.builderNode)
+                    .getHashJoinConjuncts().get(ctx.exprOrder);
             if (equal instanceof NullSafeEqual) {
                 if (join.getJoinType().isOuterJoin()) {
                     return false;
                 }
             }
         }
-        AbstractPhysicalPlan leftNode = (AbstractPhysicalPlan) join.child(0);
-        AbstractPhysicalPlan rightNode = (AbstractPhysicalPlan) join.child(1);
-        Set<Expression> probExprList = Sets.newLinkedHashSet();
-        probExprList.add(ctx.probeExpr);
-        Pair<PhysicalRelation, Slot> srcPair = 
ctx.rfContext.getAliasTransferMap().get(ctx.srcExpr);
-        PhysicalRelation srcNode = (srcPair == null) ? null : srcPair.first;
-        Pair<PhysicalRelation, Slot> targetPair = 
ctx.rfContext.getAliasTransferMap().get(ctx.probeSlot);
-        if (targetPair == null) {
-            /* cases for "targetPair is null"
-             when probeExpr is output slot of setOperator, targetPair is null
-            */
-            return false;
+
+        boolean pushed = false;
+        // Push to children whose output contains the probe slots
+        Plan leftNode = join.child(0);
+        Plan rightNode = join.child(1);
+        if 
(leftNode.getOutputSet().containsAll(ctx.probeExpr.getInputSlots())) {
+            pushed |= leftNode.accept(this, ctx);
         }
-        PhysicalRelation target1 = targetPair.first;
-        PhysicalRelation target2 = null;
-        if (ConnectContext.get() != null && 
ConnectContext.get().getSessionVariable().expandRuntimeFilterByInnerJoin) {
-            if (!join.equals(ctx.builderNode)
-                    && (join.getJoinType() == JoinType.INNER_JOIN || 
join.getJoinType().isSemiJoin())) {
-                for (Expression expr : join.getHashJoinConjuncts()) {
-                    EqualPredicate equalTo = (EqualPredicate) expr;
-                    if (ctx.probeExpr.equals(equalTo.left())) {
-                        probExprList.add(equalTo.right());
-                        targetPair = 
ctx.rfContext.getAliasTransferMap().get(equalTo.right());
-                        target2 = (targetPair == null) ? null : 
targetPair.first;
-                    } else if (ctx.probeExpr.equals(equalTo.right())) {
-                        probExprList.add(equalTo.left());
-                        targetPair = 
ctx.rfContext.getAliasTransferMap().get(equalTo.left());
-                        target2 = (targetPair == null) ? null : 
targetPair.first;
+        if 
(rightNode.getOutputSet().containsAll(ctx.probeExpr.getInputSlots())) {
+            pushed |= rightNode.accept(this, ctx);
+        }
+
+        // Expand through join conditions at non-builder inner/semi joins
+        if (!join.equals(ctx.builderNode)
+                && ConnectContext.get() != null
+                && 
ConnectContext.get().getSessionVariable().expandRuntimeFilterByInnerJoin
+                && (join.getJoinType() == JoinType.INNER_JOIN || 
join.getJoinType().isSemiJoin())) {
+            for (Expression expr : join.getHashJoinConjuncts()) {
+                EqualPredicate equalTo = (EqualPredicate) expr;
+                Expression newTarget = null;
+                if (ctx.probeExpr.equals(equalTo.left())) {
+                    newTarget = equalTo.right();
+                } else if (ctx.probeExpr.equals(equalTo.right())) {
+                    newTarget = equalTo.left();
+                }
+                if (newTarget != null && newTarget.getInputSlots().size() == 1
+                        && !newTarget.equals(ctx.srcExpr)) {
+                    PushDownContext expanded = 
ctx.withNewProbeExpression(newTarget);

Review Comment:
   The old implementation recorded `RuntimeFilterContext.ExpandRF` metadata 
here when `expand_runtime_filter_by_inner_join` created a transitive target. 
`RuntimeFilterPruner.visitPhysicalHashJoin()` still relies on 
`getExpandRfByJoin(join)` in the default `enableRuntimeFilterPrune=true` path, 
but after this refactor nothing ever appends to `expandedRF` anymore. That 
makes the expanded-target pruning branch unreachable and changes the default 
behavior for join chains whose build side is an `EffectiveSrcType.REF`. If the 
pruning logic is still needed, this metadata has to be preserved or the pruner 
needs to be updated in the same PR.



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/RuntimeFilterPushDownVisitor.java:
##########
@@ -146,37 +123,25 @@ public static PushDownContext 
createPushDownContextForNljMinMaxFilter(Expression
         public static PushDownContext 
createPushDownContextForHashJoin(Expression srcExpr, Expression probeExpr,
                 RuntimeFilterContext rfContext,
                 IdGenerator<RuntimeFilterId> rfIdGen, TRuntimeFilterType type,
-                AbstractPhysicalJoin<? extends Plan, ? extends Plan> 
builderNode,
+                AbstractPhysicalPlan builderNode,
                 boolean hasUnknownColStats, long buildSideNdv, int exprOrder) {
             return new PushDownContext(srcExpr, probeExpr, rfContext, rfIdGen, 
type, builderNode,
                     hasUnknownColStats, buildSideNdv,
                     exprOrder, false, TMinMaxRuntimeFilterType.MIN_MAX);
         }
 
+        /**
+         * A context is valid if probeExpr references exactly one input slot.
+         * Invalid when probeExpr is a constant (e.g., from OneRowRelation) or 
multi-slot.
+         */
         public boolean isValid() {
-            return finalTarget != null && probeSlot != null;
+            return probeExpr.getInputSlots().size() == 1;

Review Comment:
   This broadens join/NLJ runtime-filter targets from the old 
`slot-or-cast-on-slot` rule to any one-slot expression. That is not just a 
refactor: it re-enables expensive probe expressions like 
`substring(...)`/`abs(...)` on scan nodes. The updated 
`shape_check/.../query8.out` baselines already show a new `substring(s_zip, 1, 
2)` RF that v1 deliberately refused to build. If the goal here is only to reuse 
the v2 pushdown walker, we still need the old join-side guard (or some 
equivalent cost gate) so we do not regress scan CPU by evaluating arbitrary 
functions on every row.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to