xzj7019 opened a new pull request, #24568:
URL: https://github.com/apache/doris/pull/24568

   ## Proposed changes
   
   Current multi-window plan generation has problem on the project sequence, 
for example:
   | |  +--LogicalWindow ( windowExpressions=[avg(sum_sales#115) 
WindowSpec(PARTITION BY i_category#12, i_brand#8, cc_name#90, d_year#62 RANGE 
BETWEEN UNBOUNDED_PRECEDING AND CURRENT_ROW) AS `avg_monthly_sales`#116, rank() 
WindowSpec(PARTITION BY i_category#12, i_brand#8, cc_name#90 ORDER BY d_year#62 
asc null first, d_moy#64 asc null first RANGE BETWEEN UNBOUNDED_PRECEDING AND 
CURRENT_ROW) AS `rn`#117], isChecked=true ) |
   
   and correspond physical plan is:
   
   | |  +--PhysicalWindow[6572]@16 ( 
windowFrameGroup=(Funcs=[avg(sum_sales#115) WindowSpec(PARTITION BY 
i_category#12, i_brand#8, cc_name#90, d_year#62 RANGE BETWEEN 
UNBOUNDED_PRECEDING AND CURRENT_ROW) AS `avg_monthly_sales`#116], 
PartitionKeys=[i_category#12, i_brand#8, cc_name#90, d_year#62], OrderKeys=[], 
WindowFrame=WindowFrame(RANGE, UNBOUNDED_PRECEDING, CURRENT_ROW)), 
requiredProperties=[DistributionSpecHash ( orderedShuffledColumns=[12, 8, 90, 
62], shuffleType=REQUIRE, tableId=-1, selectedIndexId=-1, partitionIds=[], 
equivalenceExprIds=[[12], [8], [90], [62]], exprIdToEquivalenceSet={90=2, 12=0, 
62=3, 8=1} ) Order: ([i_category#12 asc, i_brand#8 asc, cc_name#90 asc, 
d_year#62 asc])] )                                                              
                                                                                
                                                                                
                                                                          
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                     |
   | |        +--PhysicalWindow[6568]@29 ( windowFrameGroup=(Funcs=[rank() 
WindowSpec(PARTITION BY i_category#12, i_brand#8, cc_name#90 ORDER BY d_year#62 
asc null first, d_moy#64 asc null first RANGE BETWEEN UNBOUNDED_PRECEDING AND 
CURRENT_ROW) AS `rn`#117], PartitionKeys=[i_category#12, i_brand#8, 
cc_name#90], OrderKeys=[d_year#62 asc null first, d_moy#64 asc null first], 
WindowFrame=WindowFrame(RANGE, UNBOUNDED_PRECEDING, CURRENT_ROW)), 
requiredProperties=[DistributionSpecHash ( orderedShuffledColumns=[12, 8, 90], 
shuffleType=REQUIRE, tableId=-1, selectedIndexId=-1, partitionIds=[], 
equivalenceExprIds=[[12], [8], [90]], exprIdToEquivalenceSet={90=2, 12=0, 8=1} 
) Order: ([i_category#12 asc, i_brand#8 asc, cc_name#90 asc, d_year#62 asc null 
first, d_moy#64 asc null first])] ) |
   
   If the final plan is generated as following:
   |   MultiCastDataSinks                                                       
                                                                             |  
                                                                                
                         |
   |   STREAM DATA SINK                                                         
                                                                             |
   |     EXCHANGE ID: 20                                                        
                                                                             |
   |     HASH_PARTITIONED: rn[#208], i_brand[#202], cc_name[#203], 
i_category[#201]                                                                
          |
   
   Before we eventually resolve the multi-window issue, we add a projection as 
following and force a mapping but this will not cover all potential problems.
   |   MultiCastDataSinks                                                       
                                                                           |
   |   STREAM DATA SINK                                                         
                                                                           |
   |     EXCHANGE ID: 20                                                        
                                                                           |
   |     HASH_PARTITIONED: rn[#219], i_brand[#213], cc_name[#214], 
i_category[#212]                                                                
        |
   |     PROJECTIONS: i_category[#184], i_brand[#185], cc_name[#186], 
d_year[#187], d_moy[#188], sum_sales[#189], avg_monthly_sales[#191], rn[#190]   
     |
   |     PROJECTION TUPLE: 20                                                   
                                                                           |
   
   
   
   <!--Describe your changes.-->
   
   ## Further comments
   
   If this is a relatively large or complex change, kick off the discussion at 
[[email protected]](mailto:[email protected]) by explaining why you 
chose the solution you did and what alternatives you considered, etc...
   
   


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