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

starocean999 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 9261c8b3853 [fix](nereids) logical apply don't include right child's 
data trait (#50528)
9261c8b3853 is described below

commit 9261c8b38533acaa450b8aa110c48816762f934c
Author: yujun <yu...@selectdb.com>
AuthorDate: Tue Apr 29 17:34:24 2025 +0800

    [fix](nereids) logical apply don't include right child's data trait (#50528)
    
    logical apply shouldnot include right child's data trait, it's use to
    desc the subquery, but the subquery's data trait may not keep in upper
    plans. This PR fix this.
    
    for example:
    
    for sql
    
    `select * from t1 where t1.x = 1 or exists(select * from t2 where t2.y =
    10 and t1.y = t2.y and t1.z = t1.u);`
    
    the outer where will become a plan filter:
    
    ```
    LogicalFilter1(t1.x = 1 or ifnull(xx, false)
    |
    |-- LogicalProject1
                |
                |-- LogicalApply
                             |
                             |-- LogicalOlapScan(t1)
                             |
                             |-- LogicalProject2
                                         |
                                         |-- LogicalFitler2 (t2.y = 10 and t1.y 
= t2.y and t1.z = t1.u)
    ```
    
    LogicalApply's right child LoggicalProject2 will contains equal set:
    t1.z = t1.u, but LogicalApply should not include this equal set. If
    logical apply contains it, then logical apply's parent logical project1
    will contains it, then logical filter1 will contains it later. But we
    known that, for logical filter 1, the EXISTS expression(`exists(select *
    from t2 where t2.y = 10 and t1.y = t2.y and t1.z = t1.u)`) maynot be
    true, so logical filter 1 must exclude equal set `t1.z = t1.u`
---
 .../nereids/trees/plans/logical/LogicalApply.java  | 24 ++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalApply.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalApply.java
index 0b12e225311..e575d8b7279 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalApply.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalApply.java
@@ -18,13 +18,13 @@
 package org.apache.doris.nereids.trees.plans.logical;
 
 import org.apache.doris.nereids.memo.GroupExpression;
+import org.apache.doris.nereids.properties.DataTrait;
 import org.apache.doris.nereids.properties.LogicalProperties;
 import org.apache.doris.nereids.trees.expressions.Expression;
 import org.apache.doris.nereids.trees.expressions.MarkJoinSlotReference;
 import org.apache.doris.nereids.trees.expressions.Slot;
 import org.apache.doris.nereids.trees.plans.Plan;
 import org.apache.doris.nereids.trees.plans.PlanType;
-import org.apache.doris.nereids.trees.plans.PropagateFuncDeps;
 import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor;
 import org.apache.doris.nereids.util.Utils;
 
@@ -41,7 +41,7 @@ import java.util.Optional;
  * @param <RIGHT_CHILD_TYPE> subquery.
  */
 public class LogicalApply<LEFT_CHILD_TYPE extends Plan, RIGHT_CHILD_TYPE 
extends Plan>
-        extends LogicalBinary<LEFT_CHILD_TYPE, RIGHT_CHILD_TYPE> implements 
PropagateFuncDeps {
+        extends LogicalBinary<LEFT_CHILD_TYPE, RIGHT_CHILD_TYPE> {
     /**
      * SubQueryType
      */
@@ -276,4 +276,24 @@ public class LogicalApply<LEFT_CHILD_TYPE extends Plan, 
RIGHT_CHILD_TYPE extends
                 compareExpr, typeCoercionExpr, correlationFilter, 
markJoinSlotReference,
                 needAddSubOutputToProjects, inProject, isMarkJoinSlotNotNull, 
children.get(0), children.get(1));
     }
+
+    @Override
+    public void computeUnique(DataTrait.Builder builder) {
+        builder.addUniqueSlot(left().getLogicalProperties().getTrait());
+    }
+
+    @Override
+    public void computeUniform(DataTrait.Builder builder) {
+        builder.addUniformSlot(left().getLogicalProperties().getTrait());
+    }
+
+    @Override
+    public void computeEqualSet(DataTrait.Builder builder) {
+        builder.addEqualSet(left().getLogicalProperties().getTrait());
+    }
+
+    @Override
+    public void computeFd(DataTrait.Builder builder) {
+        builder.addFuncDepsDG(left().getLogicalProperties().getTrait());
+    }
 }


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

Reply via email to