xy720 edited a comment on issue #6462:
URL: 
https://github.com/apache/incubator-doris/issues/6462#issuecomment-926612106


   This problem is caused by SortNode incorrectly collecting TupleIsNull 
predicate of child nodes.
   
   explain sql:
   
   ```
   
+---------------------------------------------------------------------------------------------------------------------------+
   | Explain String                                                             
                                               |
   
+---------------------------------------------------------------------------------------------------------------------------+
   | PLAN FRAGMENT 0                                                            
                                               |
   |  OUTPUT EXPRS:<slot 23> <slot 17> <slot 14> `a`.`event_day` | <slot 24> 
<slot 18> <slot 15> `a`.`medal_level` | <slot 22> |
   |   PARTITION: HASH_PARTITIONED: <slot 18> <slot 15> `a`.`medal_level`       
                                               |
   |                                                                            
                                               |
   |   RESULT SINK                                                              
                                               |
   |                                                                            
                                               |
   |   7:ANALYTIC                                                               
                                               |
   |   |  functions: [, sum(<slot 25> <slot 19> count(<slot 16> `t`.`uid`)), ]  
                                               |
   |   |  partition by: <slot 18> <slot 15> `a`.`medal_level`                   
                                               |
   |   |  order by: <slot 23> <slot 17> <slot 14> `a`.`event_day` ASC NULLS 
FIRST                                              |
   |   |  window: RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW             
                                               |
   |   |                                                                        
                                               |
   |   6:SORT                                                                   
                                               |
   |   |  order by: <slot 24> <slot 18> <slot 15> `a`.`medal_level` ASC, <slot 
23> <slot 17> <slot 14> `a`.`event_day` ASC     |
   |   |  offset: 0                                                             
                                               |
   |   |                                                                        
                                               |
   |   9:EXCHANGE                                                               
                                               |
   |                                                                            
                                               |
   | PLAN FRAGMENT 1                                                            
                                               |
   |  OUTPUT EXPRS:                                                             
                                               |
   |   PARTITION: RANDOM                                                        
                                               |
   |                                                                            
                                               |
   |   STREAM DATA SINK                                                         
                                               |
   |     EXCHANGE ID: 09                                                        
                                               |
   |     HASH_PARTITIONED: <slot 18> <slot 15> `a`.`medal_level`                
                                               |
   |                                                                            
                                               |
   |   5:AGGREGATE (update finalize)                                            
                                               |
   |   |  output: count(<slot 16> `t`.`uid`)                                    
                                               |
   |   |  group by: <slot 14> `a`.`event_day`, <slot 15> `a`.`medal_level`      
                                               |
   |   |  cardinality=-1                                                        
                                               |
   |   |                                                                        
                                               |
   |   4:AGGREGATE (update serialize)                                           
                                               |
   |   |  group by: `event_day`, `medal_level`, if(TupleIsNull(3), NULL, <slot 
8> `uid`)                                       |
   |   |  cardinality=-1                                                        
                                               |
   |   |                                                                        
                                               |
   |   3:HASH JOIN                                                              
                                               |
   |   |  join op: LEFT OUTER JOIN (BROADCAST)                                  
                                               |
   |   |  hash predicates:                                                      
                                               |
   |   |  colocate: false, reason: Inconsistent distribution of table and 
querie                                               |
   |   |  equal join conjunct: `event_day` = <slot 7> `event_day`               
                                               |
   |   |  equal join conjunct: `medal_level` = <slot 9> `medal_level`           
                                               |
   |   |  cardinality=0                                                         
                                               |
   |   |                                                                        
                                               |
   |   |----8:EXCHANGE                                                          
                                               |
   |   |                                                                        
                                               |
   |   0:OlapScanNode                                                           
                                               |
   |      TABLE: dwd_youjia_medal_new_incr_day                                  
                                               |
   |      PREAGGREGATION: OFF. Reason: conjunct on `event_day` which is 
StorageEngine value column                             |
   |      partitions=0/4                                                        
                                               |
   |      rollup: null                                                          
                                               |
   |      tabletRatio=0/0                                                       
                                               |
   |      tabletList=                                                           
                                               |
   |      cardinality=0                                                         
                                               |
   |      avgRowSize=32.0                                                       
                                               |
   |      numNodes=1                                                            
                                               |
   |                                                                            
                                               |
   | PLAN FRAGMENT 2                                                            
                                               |
   |  OUTPUT EXPRS:                                                             
                                               |
   |   PARTITION: RANDOM                                                        
                                               |
   |                                                                            
                                               |
   |   STREAM DATA SINK                                                         
                                               |
   |     EXCHANGE ID: 08                                                        
                                               |
   |     UNPARTITIONED                                                          
                                               |
   |                                                                            
                                               |
   |   2:AGGREGATE (update finalize)                                            
                                               |
   |   |  group by: `event_day`, `uid`, `medal_level`                           
                                               |
   |   |  cardinality=-1                                                        
                                               |
   |   |                                                                        
                                               |
   |   1:OlapScanNode                                                           
                                               |
   |      TABLE: dwd_youjia_medal_new_incr_day                                  
                                               |
   |      PREAGGREGATION: ON                                                    
                                               |
   |      partitions=0/4                                                        
                                               |
   |      rollup: null                                                          
                                               |
   |      tabletRatio=0/0                                                       
                                               |
   |      tabletList=                                                           
                                               |
   |      cardinality=0                                                         
                                               |
   |      avgRowSize=48.0                                                       
                                               |
   |      numNodes=1                                                            
                                               |
   
+---------------------------------------------------------------------------------------------------------------------------+
   ```
   
   The SortNode(6) has member variable `resolvedTupleExprs`, which collects 
output exprs from its child node, and will be sent to be.
   
   When collecting, it filters exprs not bound to tupleId of its child node 
within Expr.IsBoundbyTupleIds() method. (See details in 
AnalyticPlanner.java:createSortInfo()).
   
   Sometimes, when there is left join in the query, the child nodes in the tree 
will produce many TupleIsNull predicates, but we did not implement 
IsBoundbyTupleIds() method for TupleIsNull predicate. So SortNode will 
incorrectly collect wrong TupleIsNull, which may cause be core.
   


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

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