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

yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 5986d5415e2e167aba9e6143712ad980e8fe5cde
Author: minghong <engle...@gmail.com>
AuthorDate: Tue Jan 23 19:29:18 2024 +0800

    [opt](Nereids) make runtime filter target support expression (#30131)
    
    the target expression should be:
    1. only one numeric slot, or
    2. cast for any data type
    
    example:
    select * from T1 join T2 on abs(T1.a) = T2.a
    RF T2.a->abs(T1.a)
---
 .../glue/translator/RuntimeFilterTranslator.java   |  25 +++--
 .../processor/post/RuntimeFilterContext.java       |   2 +-
 .../processor/post/RuntimeFilterGenerator.java     |   8 +-
 .../trees/plans/physical/AbstractPhysicalPlan.java |   8 +-
 .../trees/plans/physical/PhysicalProject.java      |  11 ++-
 .../trees/plans/physical/RuntimeFilter.java        |  22 ++---
 .../apache/doris/nereids/util/ExpressionUtils.java |  19 ++++
 .../nereids/postprocess/RuntimeFilterTest.java     |   4 +-
 .../data/nereids_p0/runtime_filter/expr-target.out |   5 +
 .../noStatsRfPrune/query64.out                     |   4 +-
 .../no_stats_shape/query64.out                     |   4 +-
 .../rf_prune/query64.out                           |   8 +-
 .../nereids_tpcds_shape_sf100_p0/shape/query64.out |   4 +-
 .../nereids_p0/runtime_filter/expr-target.groovy   | 106 +++++++++++++++++++++
 14 files changed, 180 insertions(+), 50 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/RuntimeFilterTranslator.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/RuntimeFilterTranslator.java
index 30a69ff97de..c0787c6012c 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/RuntimeFilterTranslator.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/RuntimeFilterTranslator.java
@@ -115,30 +115,27 @@ public class RuntimeFilterTranslator {
         List<Map<TupleId, List<SlotId>>> targetTupleIdMapList = new 
ArrayList<>();
         List<ScanNode> scanNodeList = new ArrayList<>();
         boolean hasInvalidTarget = false;
-        for (int i = 0; i < filter.getTargetExprs().size(); i++) {
-            Slot curTargetExpr = filter.getTargetExprs().get(i);
+        for (int i = 0; i < filter.getTargetExpressions().size(); i++) {
+            Slot curTargetSlot = filter.getTargetSlots().get(i);
             Expression curTargetExpression = 
filter.getTargetExpressions().get(i);
-            Expr target = 
context.getExprIdToOlapScanNodeSlotRef().get(curTargetExpr.getExprId());
+            Expr target = 
context.getExprIdToOlapScanNodeSlotRef().get(curTargetSlot.getExprId());
             if (target == null) {
                 context.setTargetNullCount();
                 hasInvalidTarget = true;
                 break;
             }
-            ScanNode scanNode = 
context.getScanNodeOfLegacyRuntimeFilterTarget().get(curTargetExpr);
+            ScanNode scanNode = 
context.getScanNodeOfLegacyRuntimeFilterTarget().get(curTargetSlot);
             Expr targetExpr;
-            if (filter.getType() == TRuntimeFilterType.BITMAP) {
-                if (curTargetExpression.equals(curTargetExpr)) {
-                    targetExpr = target;
-                } else {
-                    RuntimeFilterExpressionTranslator translator = new 
RuntimeFilterExpressionTranslator(
-                            context.getExprIdToOlapScanNodeSlotRef());
-                    targetExpr = curTargetExpression.accept(translator, ctx);
-                }
-            } else {
+            if (curTargetSlot.equals(curTargetExpression)) {
                 targetExpr = target;
+            } else {
+                RuntimeFilterExpressionTranslator translator = new 
RuntimeFilterExpressionTranslator(
+                        context.getExprIdToOlapScanNodeSlotRef());
+                targetExpr = curTargetExpression.accept(translator, ctx);
             }
+
             // adjust data type
-            if (!src.getType().equals(target.getType()) && filter.getType() != 
TRuntimeFilterType.BITMAP) {
+            if (!src.getType().equals(targetExpr.getType()) && 
filter.getType() != TRuntimeFilterType.BITMAP) {
                 targetExpr = new CastExpr(src.getType(), targetExpr);
             }
             SlotRef targetSlot = target.getSrcSlotRef();
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/RuntimeFilterContext.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/RuntimeFilterContext.java
index 5e412f61ca3..2e8055ca783 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/RuntimeFilterContext.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/RuntimeFilterContext.java
@@ -206,7 +206,7 @@ public class RuntimeFilterContext {
     }
 
     public void setTargetExprIdToFilter(ExprId id, RuntimeFilter filter) {
-        
Preconditions.checkArgument(filter.getTargetExprs().stream().anyMatch(expr -> 
expr.getExprId() == id));
+        
Preconditions.checkArgument(filter.getTargetSlots().stream().anyMatch(expr -> 
expr.getExprId() == id));
         this.targetExprIdToFilter.computeIfAbsent(id, k -> 
Lists.newArrayList()).add(filter);
     }
 
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 8a75ad36c5a..85f246998d4 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
@@ -315,7 +315,7 @@ public class RuntimeFilterGenerator extends 
PlanPostProcessor {
             if (expression.children().isEmpty()) {
                 continue;
             }
-            Expression expr = 
ExpressionUtils.getExpressionCoveredByCast(expression.child(0));
+            Expression expr = 
ExpressionUtils.getSingleNumericSlotOrExpressionCoveredByCast(expression.child(0));
             if (expr instanceof NamedExpression
                     && ctx.aliasTransferMapContains((NamedExpression) expr)) {
                 if (expression instanceof Alias) {
@@ -357,7 +357,7 @@ public class RuntimeFilterGenerator extends 
PlanPostProcessor {
     }
 
     public static Slot checkTargetChild(Expression leftChild) {
-        Expression expression = 
ExpressionUtils.getExpressionCoveredByCast(leftChild);
+        Expression expression = 
ExpressionUtils.getSingleNumericSlotOrExpressionCoveredByCast(leftChild);
         return expression instanceof Slot ? ((Slot) expression) : null;
     }
 
@@ -611,6 +611,7 @@ public class RuntimeFilterGenerator extends 
PlanPostProcessor {
                         (SlotReference) targetExpr, ctx);
                 if (!pushDownBasicTableInfos.isEmpty()) {
                     List<Slot> targetList = new ArrayList<>();
+                    List<Expression> targetExpressions = new ArrayList<>();
                     List<PhysicalRelation> targetNodes = new ArrayList<>();
                     for (Map.Entry<Slot, PhysicalRelation> entry : 
pushDownBasicTableInfos.entrySet()) {
                         Slot targetSlot = entry.getKey();
@@ -619,6 +620,7 @@ public class RuntimeFilterGenerator extends 
PlanPostProcessor {
                             continue;
                         }
                         targetList.add(targetSlot);
+                        targetExpressions.add(targetSlot);
                         targetNodes.add(scan);
                         ctx.addJoinToTargetMap(join, targetSlot.getExprId());
                         ctx.setTargetsOnScanNode(scan, targetSlot);
@@ -626,7 +628,7 @@ public class RuntimeFilterGenerator extends 
PlanPostProcessor {
                     // build multi-target runtime filter
                     // since always on different join, set the expr_order as 0
                     RuntimeFilter filter = new 
RuntimeFilter(generator.getNextId(),
-                            equalTo.right(), targetList, type, 0, join, 
buildSideNdv, cteNode);
+                            equalTo.right(), targetList, targetExpressions, 
type, 0, join, buildSideNdv, cteNode);
                     targetNodes.forEach(node -> 
node.addAppliedRuntimeFilter(filter));
                     for (Slot slot : targetList) {
                         ctx.setTargetExprIdToFilter(slot.getExprId(), filter);
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/AbstractPhysicalPlan.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/AbstractPhysicalPlan.java
index 6a19abcc8fc..108fa78f808 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/AbstractPhysicalPlan.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/AbstractPhysicalPlan.java
@@ -126,19 +126,19 @@ public abstract class AbstractPhysicalPlan extends 
AbstractPlan implements Physi
                 // however, RF(B.b->A.a2) is implied by RF(B.a->A.a1) and 
A.a1=A.a2
                 // we skip RF(B.b->A.a2)
                 this.addAppliedRuntimeFilter(filter);
-                filter.addTargetSlot(scanSlot, scan);
-                filter.addTargetExpression(scanSlot);
+                filter.addTargetSlot(scanSlot, probeExpr, scan);
                 ctx.addJoinToTargetMap(builderNode, scanSlot.getExprId());
                 ctx.setTargetExprIdToFilter(scanSlot.getExprId(), filter);
                 
ctx.setTargetsOnScanNode(ctx.getAliasTransferPair((NamedExpression) 
probeExpr).first, scanSlot);
             }
         } else {
             filter = new RuntimeFilter(generator.getNextId(),
-                    src, ImmutableList.of(scanSlot), type, exprOrder, 
builderNode, buildSideNdv, scan);
+                    src, ImmutableList.of(scanSlot), 
ImmutableList.of(probeExpr),
+                    type, exprOrder, builderNode, buildSideNdv, scan);
             this.addAppliedRuntimeFilter(filter);
             ctx.addJoinToTargetMap(builderNode, scanSlot.getExprId());
             ctx.setTargetExprIdToFilter(scanSlot.getExprId(), filter);
-            
ctx.setTargetsOnScanNode(ctx.getAliasTransferPair((NamedExpression) 
probeExpr).first, scanSlot);
+            
ctx.setTargetsOnScanNode(ctx.getAliasTransferPair((NamedExpression) 
probeSlot).first, scanSlot);
             ctx.setRuntimeFilterIdentityToFilter(src, type, builderNode, 
filter);
         }
         return true;
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalProject.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalProject.java
index 18d4f36204c..8cdfedbfdd3 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalProject.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalProject.java
@@ -28,6 +28,7 @@ import org.apache.doris.nereids.trees.expressions.Alias;
 import org.apache.doris.nereids.trees.expressions.Expression;
 import org.apache.doris.nereids.trees.expressions.NamedExpression;
 import org.apache.doris.nereids.trees.expressions.Slot;
+import org.apache.doris.nereids.trees.expressions.SlotReference;
 import org.apache.doris.nereids.trees.plans.Plan;
 import org.apache.doris.nereids.trees.plans.PlanType;
 import org.apache.doris.nereids.trees.plans.algebra.Project;
@@ -198,7 +199,15 @@ public class PhysicalProject<CHILD_TYPE extends Plan> 
extends PhysicalUnary<CHIL
             if 
(!RuntimeFilterGenerator.checkPushDownPreconditionsForRelation(this, scan)) {
                 return false;
             }
-
+            if (probeExpr instanceof SlotReference) {
+                for (NamedExpression namedExpression : projects) {
+                    if (namedExpression instanceof Alias
+                            && namedExpression.getExprId() == ((SlotReference) 
probeExpr).getExprId()) {
+                        probeExpr = ((Alias) namedExpression).child();
+                        break;
+                    }
+                }
+            }
             AbstractPhysicalPlan child = (AbstractPhysicalPlan) child(0);
             return child.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/RuntimeFilter.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/RuntimeFilter.java
index 3a3b01daecd..596b1c287a6 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/RuntimeFilter.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/RuntimeFilter.java
@@ -23,7 +23,6 @@ import org.apache.doris.planner.RuntimeFilterId;
 import org.apache.doris.thrift.TMinMaxRuntimeFilterType;
 import org.apache.doris.thrift.TRuntimeFilterType;
 
-import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Lists;
 
 import java.util.List;
@@ -55,10 +54,10 @@ public class RuntimeFilter {
     /**
      * constructor
      */
-    public RuntimeFilter(RuntimeFilterId id, Expression src, List<Slot> 
targets, TRuntimeFilterType type,
-            int exprOrder, AbstractPhysicalJoin builderNode, long buildSideNdv,
+    public RuntimeFilter(RuntimeFilterId id, Expression src, List<Slot> 
targets, List<Expression> targetExpressions,
+                         TRuntimeFilterType type, int exprOrder, 
AbstractPhysicalJoin builderNode, long buildSideNdv,
                          PhysicalRelation scan) {
-        this(id, src, targets, ImmutableList.copyOf(targets), type, exprOrder,
+        this(id, src, targets, targetExpressions, type, exprOrder,
                 builderNode, false, buildSideNdv, 
TMinMaxRuntimeFilterType.MIN_MAX, scan);
     }
 
@@ -99,10 +98,6 @@ public class RuntimeFilter {
         return srcSlot;
     }
 
-    public List<Slot> getTargetExprs() {
-        return targetSlots;
-    }
-
     public RuntimeFilterId getId() {
         return id;
     }
@@ -131,7 +126,8 @@ public class RuntimeFilter {
         return buildSideNdv;
     }
 
-    public void addTargetSlot(Slot target, PhysicalRelation scan) {
+    public void addTargetSlot(Slot target, Expression targetExpression, 
PhysicalRelation scan) {
+        targetExpressions.add(targetExpression);
         targetSlots.add(target);
         targetScans.add(scan);
     }
@@ -140,10 +136,6 @@ public class RuntimeFilter {
         return targetSlots;
     }
 
-    public void addTargetExpression(Expression targetExpr) {
-        targetExpressions.add(targetExpr);
-    }
-
     public List<PhysicalRelation> getTargetScans() {
         return targetScans;
     }
@@ -156,7 +148,7 @@ public class RuntimeFilter {
     public String toString() {
         StringBuilder sb = new StringBuilder();
         sb.append("RF").append(id.asInt())
-                
.append("[").append(getSrcExpr()).append("->").append(targetSlots)
+                
.append("[").append(getSrcExpr()).append("->").append(targetExpressions)
                 .append("(ndv/size = ").append(buildSideNdv).append("/")
                 
.append(org.apache.doris.planner.RuntimeFilter.expectRuntimeFilterSize(buildSideNdv))
                 .append(")");
@@ -171,7 +163,7 @@ public class RuntimeFilter {
         StringBuilder sb = new StringBuilder();
         sb.append("RF").append(id.asInt())
                 .append(" ").append(getSrcExpr().toSql()).append("->[").append(
-                        targetSlots.stream().map(slot -> 
slot.getName()).collect(Collectors.joining(",")))
+                        targetExpressions.stream().map(expr -> 
expr.toSql()).collect(Collectors.joining(",")))
                 .append("]");
         return sb.toString();
     }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/util/ExpressionUtils.java 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/util/ExpressionUtils.java
index e78ce76bb8c..95fc942762a 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/util/ExpressionUtils.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/util/ExpressionUtils.java
@@ -742,6 +742,25 @@ public class ExpressionUtils {
         return expression;
     }
 
+    /**
+     * the expressions can be used as runtime filter targets
+     */
+    public static Expression 
getSingleNumericSlotOrExpressionCoveredByCast(Expression expression) {
+        if (expression.getInputSlots().size() == 1) {
+            Slot slot = expression.getInputSlots().iterator().next();
+            if (slot.getDataType() instanceof NumericType) {
+                return expression.getInputSlots().iterator().next();
+            }
+        }
+        // for other datatype, only support cast.
+        // example: T1 join T2 on subStr(T1.a, 1,4) = subStr(T2.a, 1,4)
+        // the cost of subStr is too high, and hence we do not generate RF 
subStr(T2.a, 1,4)->subStr(T1.a, 1,4)
+        while (expression instanceof Cast) {
+            expression = ((Cast) expression).child();
+        }
+        return expression;
+    }
+
     /**
      * To check whether a slot is constant after passing through a filter
      */
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/postprocess/RuntimeFilterTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/postprocess/RuntimeFilterTest.java
index e8753d1e5ce..ce647427d21 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/postprocess/RuntimeFilterTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/postprocess/RuntimeFilterTest.java
@@ -309,7 +309,7 @@ public class RuntimeFilterTest extends SSBTestBase {
         for (RuntimeFilter filter : filters) {
             Assertions.assertTrue(colNames.contains(Pair.of(
                     filter.getSrcExpr().toSql(),
-                    filter.getTargetExprs().get(0).getName())));
+                    filter.getTargetSlots().get(0).getName())));
         }
     }
 
@@ -318,7 +318,7 @@ public class RuntimeFilterTest extends SSBTestBase {
         for (RuntimeFilter filter : filters) {
             srcTargets.contains(Pair.of(
                     filter.getSrcExpr().toSql(),
-                    
filter.getTargetExprs().stream().collect(Collectors.toSet())
+                    
filter.getTargetSlots().stream().collect(Collectors.toSet())
             ));
         }
     }
diff --git a/regression-test/data/nereids_p0/runtime_filter/expr-target.out 
b/regression-test/data/nereids_p0/runtime_filter/expr-target.out
new file mode 100644
index 00000000000..e0bb3e0d3d5
--- /dev/null
+++ b/regression-test/data/nereids_p0/runtime_filter/expr-target.out
@@ -0,0 +1,5 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !abs --
+-1     -1      -1      1       1       1
+1      1       1       1       1       1
+
diff --git 
a/regression-test/data/nereids_tpcds_shape_sf100_p0/noStatsRfPrune/query64.out 
b/regression-test/data/nereids_tpcds_shape_sf100_p0/noStatsRfPrune/query64.out
index eb79094ac60..1edae4186bc 100644
--- 
a/regression-test/data/nereids_tpcds_shape_sf100_p0/noStatsRfPrune/query64.out
+++ 
b/regression-test/data/nereids_tpcds_shape_sf100_p0/noStatsRfPrune/query64.out
@@ -5,7 +5,7 @@ PhysicalCteAnchor ( cteId=CTEId#1 )
 ----PhysicalProject
 ------hashAgg[LOCAL]
 --------PhysicalProject
-----------hashJoin[INNER_JOIN] hashCondition=((store_sales.ss_item_sk = 
item.i_item_sk)) otherCondition=() build RFs:RF19 
i_item_sk->[ss_item_sk,sr_item_sk,cs_item_sk]
+----------hashJoin[INNER_JOIN] hashCondition=((store_sales.ss_item_sk = 
item.i_item_sk)) otherCondition=() build RFs:RF19 
i_item_sk->[ss_item_sk,sr_item_sk,cs_item_sk,cr_item_sk]
 ------------PhysicalDistribute[DistributionSpecHash]
 --------------PhysicalProject
 ----------------hashJoin[INNER_JOIN] hashCondition=((hd2.hd_income_band_sk = 
ib2.ib_income_band_sk)) otherCondition=()
@@ -51,7 +51,7 @@ PhysicalCteAnchor ( cteId=CTEId#1 )
 
------------------------------------------------------------------------------------PhysicalProject
 
--------------------------------------------------------------------------------------PhysicalOlapScan[catalog_sales]
 apply RFs: RF19
 
------------------------------------------------------------------------------------PhysicalProject
---------------------------------------------------------------------------------------PhysicalOlapScan[catalog_returns]
+--------------------------------------------------------------------------------------PhysicalOlapScan[catalog_returns]
 apply RFs: RF19
 
--------------------------------------------------------------PhysicalDistribute[DistributionSpecHash]
 ----------------------------------------------------------------PhysicalProject
 
------------------------------------------------------------------PhysicalOlapScan[customer]
diff --git 
a/regression-test/data/nereids_tpcds_shape_sf100_p0/no_stats_shape/query64.out 
b/regression-test/data/nereids_tpcds_shape_sf100_p0/no_stats_shape/query64.out
index e3b2f84df37..ab0640721b4 100644
--- 
a/regression-test/data/nereids_tpcds_shape_sf100_p0/no_stats_shape/query64.out
+++ 
b/regression-test/data/nereids_tpcds_shape_sf100_p0/no_stats_shape/query64.out
@@ -5,7 +5,7 @@ PhysicalCteAnchor ( cteId=CTEId#1 )
 ----PhysicalProject
 ------hashAgg[LOCAL]
 --------PhysicalProject
-----------hashJoin[INNER_JOIN] hashCondition=((store_sales.ss_item_sk = 
item.i_item_sk)) otherCondition=() build RFs:RF19 
i_item_sk->[ss_item_sk,sr_item_sk,cs_item_sk]
+----------hashJoin[INNER_JOIN] hashCondition=((store_sales.ss_item_sk = 
item.i_item_sk)) otherCondition=() build RFs:RF19 
i_item_sk->[ss_item_sk,sr_item_sk,cs_item_sk,cr_item_sk]
 ------------PhysicalDistribute[DistributionSpecHash]
 --------------PhysicalProject
 ----------------hashJoin[INNER_JOIN] hashCondition=((hd2.hd_income_band_sk = 
ib2.ib_income_band_sk)) otherCondition=() build RFs:RF18 
ib_income_band_sk->[hd_income_band_sk]
@@ -51,7 +51,7 @@ PhysicalCteAnchor ( cteId=CTEId#1 )
 
------------------------------------------------------------------------------------PhysicalProject
 
--------------------------------------------------------------------------------------PhysicalOlapScan[catalog_sales]
 apply RFs: RF0 RF1 RF19
 
------------------------------------------------------------------------------------PhysicalProject
---------------------------------------------------------------------------------------PhysicalOlapScan[catalog_returns]
+--------------------------------------------------------------------------------------PhysicalOlapScan[catalog_returns]
 apply RFs: RF19
 
--------------------------------------------------------------PhysicalDistribute[DistributionSpecHash]
 ----------------------------------------------------------------PhysicalProject
 
------------------------------------------------------------------PhysicalOlapScan[customer]
 apply RFs: RF8 RF10 RF11 RF14 RF15
diff --git 
a/regression-test/data/nereids_tpcds_shape_sf100_p0/rf_prune/query64.out 
b/regression-test/data/nereids_tpcds_shape_sf100_p0/rf_prune/query64.out
index 367d659e25c..c93884d378a 100644
--- a/regression-test/data/nereids_tpcds_shape_sf100_p0/rf_prune/query64.out
+++ b/regression-test/data/nereids_tpcds_shape_sf100_p0/rf_prune/query64.out
@@ -31,7 +31,7 @@ PhysicalCteAnchor ( cteId=CTEId#1 )
 ------------------------------------------------PhysicalProject
 
--------------------------------------------------PhysicalOlapScan[customer_demographics]
 apply RFs: RF12
 
----------------------------------------------PhysicalDistribute[DistributionSpecHash]
-------------------------------------------------hashJoin[INNER_JOIN] 
hashCondition=((store_sales.ss_item_sk = item.i_item_sk)) otherCondition=() 
build RFs:RF11 i_item_sk->[ss_item_sk,cs_item_sk]
+------------------------------------------------hashJoin[INNER_JOIN] 
hashCondition=((store_sales.ss_item_sk = item.i_item_sk)) otherCondition=() 
build RFs:RF11 i_item_sk->[ss_item_sk,cs_item_sk,cr_item_sk]
 --------------------------------------------------PhysicalProject
 ----------------------------------------------------hashJoin[INNER_JOIN] 
hashCondition=((store_sales.ss_store_sk = store.s_store_sk)) otherCondition=()
 ------------------------------------------------------PhysicalProject
@@ -51,11 +51,11 @@ PhysicalCteAnchor ( cteId=CTEId#1 )
 
------------------------------------------------------------------------------PhysicalDistribute[DistributionSpecHash]
 
--------------------------------------------------------------------------------hashAgg[LOCAL]
 
----------------------------------------------------------------------------------PhysicalProject
-------------------------------------------------------------------------------------hashJoin[INNER_JOIN]
 hashCondition=((catalog_sales.cs_item_sk = catalog_returns.cr_item_sk) and 
(catalog_sales.cs_order_number = catalog_returns.cr_order_number)) 
otherCondition=() build RFs:RF4 cr_order_number->[cs_order_number];RF5 
cr_item_sk->[cs_item_sk]
+------------------------------------------------------------------------------------hashJoin[INNER_JOIN]
 hashCondition=((catalog_sales.cs_item_sk = catalog_returns.cr_item_sk) and 
(catalog_sales.cs_order_number = catalog_returns.cr_order_number)) 
otherCondition=()
 
--------------------------------------------------------------------------------------PhysicalProject
-----------------------------------------------------------------------------------------PhysicalOlapScan[catalog_sales]
 apply RFs: RF4 RF5 RF11
+----------------------------------------------------------------------------------------PhysicalOlapScan[catalog_sales]
 apply RFs: RF11
 
--------------------------------------------------------------------------------------PhysicalProject
-----------------------------------------------------------------------------------------PhysicalOlapScan[catalog_returns]
+----------------------------------------------------------------------------------------PhysicalOlapScan[catalog_returns]
 apply RFs: RF11
 
------------------------------------------------------------------PhysicalDistribute[DistributionSpecReplicated]
 
--------------------------------------------------------------------PhysicalProject
 
----------------------------------------------------------------------filter(d_year
 IN (2001, 2002))
diff --git 
a/regression-test/data/nereids_tpcds_shape_sf100_p0/shape/query64.out 
b/regression-test/data/nereids_tpcds_shape_sf100_p0/shape/query64.out
index d40500b774a..e1bb4def1c6 100644
--- a/regression-test/data/nereids_tpcds_shape_sf100_p0/shape/query64.out
+++ b/regression-test/data/nereids_tpcds_shape_sf100_p0/shape/query64.out
@@ -31,7 +31,7 @@ PhysicalCteAnchor ( cteId=CTEId#1 )
 ------------------------------------------------PhysicalProject
 
--------------------------------------------------PhysicalOlapScan[customer_demographics]
 apply RFs: RF12
 
----------------------------------------------PhysicalDistribute[DistributionSpecHash]
-------------------------------------------------hashJoin[INNER_JOIN] 
hashCondition=((store_sales.ss_item_sk = item.i_item_sk)) otherCondition=() 
build RFs:RF11 i_item_sk->[ss_item_sk,cs_item_sk]
+------------------------------------------------hashJoin[INNER_JOIN] 
hashCondition=((store_sales.ss_item_sk = item.i_item_sk)) otherCondition=() 
build RFs:RF11 i_item_sk->[ss_item_sk,cs_item_sk,cr_item_sk]
 --------------------------------------------------PhysicalProject
 ----------------------------------------------------hashJoin[INNER_JOIN] 
hashCondition=((store_sales.ss_store_sk = store.s_store_sk)) otherCondition=() 
build RFs:RF10 s_store_sk->[ss_store_sk]
 ------------------------------------------------------PhysicalProject
@@ -55,7 +55,7 @@ PhysicalCteAnchor ( cteId=CTEId#1 )
 
--------------------------------------------------------------------------------------PhysicalProject
 
----------------------------------------------------------------------------------------PhysicalOlapScan[catalog_sales]
 apply RFs: RF4 RF5 RF11
 
--------------------------------------------------------------------------------------PhysicalProject
-----------------------------------------------------------------------------------------PhysicalOlapScan[catalog_returns]
+----------------------------------------------------------------------------------------PhysicalOlapScan[catalog_returns]
 apply RFs: RF11
 
------------------------------------------------------------------PhysicalDistribute[DistributionSpecReplicated]
 
--------------------------------------------------------------------PhysicalProject
 
----------------------------------------------------------------------filter(d_year
 IN (2001, 2002))
diff --git 
a/regression-test/suites/nereids_p0/runtime_filter/expr-target.groovy 
b/regression-test/suites/nereids_p0/runtime_filter/expr-target.groovy
new file mode 100644
index 00000000000..9480b860ac7
--- /dev/null
+++ b/regression-test/suites/nereids_p0/runtime_filter/expr-target.groovy
@@ -0,0 +1,106 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("expr-target") {
+    String db = context.config.getDbNameByFile(context.file)
+    sql "use ${db}"
+    sql "drop table if exists rfexpA"
+    sql """
+        CREATE TABLE rfexpA (
+        a1 INT NOT NULL,
+        a2 VARCHAR(25) NOT NULL,
+        a3 VARCHAR(152) NULL
+        ) ENGINE=OLAP
+        DUPLICATE KEY(a1)
+        COMMENT 'OLAP'
+        DISTRIBUTED BY HASH(a1) BUCKETS 1
+        PROPERTIES (
+        "replication_allocation" = "tag.location.default: 1",
+        "min_load_replica_num" = "-1",
+        "is_being_synced" = "false",
+        "storage_format" = "V2",
+        "light_schema_change" = "true",
+        "disable_auto_compaction" = "false",
+        "enable_single_replica_compaction" = "false",
+        "group_commit_interval_ms" = "10000",
+        "group_commit_data_bytes" = "134217728"
+        ); 
+        """
+
+    sql "drop table if exists rfexpB"
+    sql """
+        CREATE TABLE rfexpB (
+        b1 INT NOT NULL,
+        b2 VARCHAR(25) NOT NULL,
+        b3 VARCHAR(152) NULL
+        ) ENGINE=OLAP
+        DUPLICATE KEY(b1)
+        COMMENT 'OLAP'
+        DISTRIBUTED BY HASH(b1) BUCKETS 1
+        PROPERTIES (
+        "replication_allocation" = "tag.location.default: 1",
+        "min_load_replica_num" = "-1",
+        "is_being_synced" = "false",
+        "storage_format" = "V2",
+        "light_schema_change" = "true",
+        "disable_auto_compaction" = "false",
+        "enable_single_replica_compaction" = "false",
+        "group_commit_interval_ms" = "10000",
+        "group_commit_data_bytes" = "134217728"
+        ); 
+        """
+    sql """
+        insert into rfexpA values (1, 1, 1), (2, 2, 2),(-1,-1, -1);
+    """
+    sql """
+        insert into rfexpB values (1,1,1), (4,4,4);
+    """
+    
+    sql "set enable_nereids_planner=true";
+    sql "set forbid_unknown_col_stats=false"
+    sql "set disable_join_reorder=true"
+    sql "set enable_runtime_filter_prune=false"
+
+    explain {
+        sql "select * from rfexpA join rfexpB on abs(rfexpA.a1) = rfexpB.b1;"
+        contains("RF000")
+    }
+
+    explain {
+        sql "select * from rfexpA join rfexpB on abs(rfexpA.a1 + rfexpA.a2) = 
rfexpB.b1;"
+        notContains("RF000")
+    }
+
+    explain {
+        sql "select * from rfexpA join rfexpB on abs(rfexpA.a1 + rfexpA.a1) = 
rfexpB.b1;"
+        contains("RF000")
+    }
+
+    explain {
+        sql """
+            select * 
+            from 
+                (select a1 + 1 as a1
+                from rfexpA
+                ) T
+                join rfexpB on T.a1 = rfexpB.b1;
+            """
+        contains("RF000")
+    }
+
+    qt_abs "select * from rfexpA join rfexpB on abs(rfexpA.a1) = rfexpB.b1"
+}
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to