cambyzju opened a new issue, #39740:
URL: https://github.com/apache/doris/issues/39740

   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no 
similar issues.
   
   
   ### Description
   
   Step 1: create three tables with same schema, and insert some example data:
   ```
   CREATE TABLE `a` (
     `k1` INT NOT NULL,
     `k2` INT NOT NULL,
     `v` INT NULL
   ) ENGINE=OLAP
   DUPLICATE KEY(`k1`, `k2`)
   COMMENT 'OLAP'
   DISTRIBUTED BY HASH(`k1`) BUCKETS 1
   PROPERTIES ("replication_num"="1");
   
   CREATE TABLE `b` (
     `k1` INT NOT NULL,
     `k2` INT NOT NULL,
     `v` INT NULL
   ) ENGINE=OLAP
   DUPLICATE KEY(`k1`, `k2`)
   COMMENT 'OLAP'
   DISTRIBUTED BY HASH(`k1`) BUCKETS 1
   PROPERTIES ("replication_num"="1");
   
   CREATE TABLE `c` (
     `k1` INT NOT NULL,
     `k2` INT NOT NULL,
     `v` INT NULL
   ) ENGINE=OLAP
   DUPLICATE KEY(`k1`, `k2`)
   COMMENT 'OLAP'
   DISTRIBUTED BY HASH(`k1`) BUCKETS 1
   PROPERTIES ("replication_num"="1");
   
   INSERT INTO a VALUES(1,2,3),(4,5,6);
   INSERT INTO b VALUES(1,2,3),(4,5,6);
   INSERT INTO c VALUES(1,2,3),(4,5,6);
   ```
   
   Step 2: Use one left join like bellow, we found `y.k1=1 ` generated and 
pushed down to table b
   ```
   > explain shape plan select * from a as x left join b as y on x.k1 = y.k1 
where x.k1=1;
   
+-------------------------------------------------------------------------------+
   | Explain String(Nereids Planner)                                            
   |
   
+-------------------------------------------------------------------------------+
   | PhysicalResultSink                                                         
   |
   | --PhysicalDistribute[DistributionSpecGather]                               
   |
   | ----hashJoin[LEFT_OUTER_JOIN] hashCondition=((x.k1 = y.k1)) 
otherCondition=() |
   | ------filter((x.k1 = 1))                                                   
   |
   | --------PhysicalOlapScan[a]                                                
   |
   | ------PhysicalDistribute[DistributionSpecHash]                             
   |
   | --------filter((y.k1 = 1))                                                 
   |
   | ----------PhysicalOlapScan[b]                                              
   |
   
+-------------------------------------------------------------------------------+
   ```
   
   Step 3: But if we replace table y with another left join, we found `y.k1=1` 
only pushed to join node, not pushed to table b and c
   ```
   > explain shape plan select * from a as x left join (select c.k1 as k1 from 
b left join c on b.k1=c.k1) as y on x.k1 = y.k1 where x.k1=1;
   
+-------------------------------------------------------------------------------------+
   | Explain String(Nereids Planner)                                            
         |
   
+-------------------------------------------------------------------------------------+
   | PhysicalResultSink                                                         
         |
   | --PhysicalDistribute[DistributionSpecGather]                               
         |
   | ----hashJoin[LEFT_OUTER_JOIN] hashCondition=((x.k1 = y.k1)) 
otherCondition=()       |
   | ------filter((x.k1 = 1))                                                   
         |
   | --------PhysicalOlapScan[a]                                                
         |
   | ------PhysicalDistribute[DistributionSpecHash]                             
         |
   | --------PhysicalProject                                                    
         |
   | ----------filter((y.k1 = 1))                                               
         |
   | ------------hashJoin[LEFT_OUTER_JOIN] hashCondition=((b.k1 = k1)) 
otherCondition=() |
   | --------------PhysicalProject                                              
         |
   | ----------------PhysicalOlapScan[b]                                        
         |
   | --------------PhysicalDistribute[DistributionSpecHash]                     
         |
   | ----------------PhysicalProject                                            
         |
   | ------------------PhysicalOlapScan[c]                                      
         |
   
+-------------------------------------------------------------------------------------+
   ```
   
   ### Solution
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
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: commits-unsubscr...@doris.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to