jiaqizho opened a new issue, #1288:
URL: https://github.com/apache/cloudberry/issues/1288

   ### Apache Cloudberry version
   
   _No response_
   
   ### What happened
   
   ```
   regression=# explain SELECT last_value(ten) OVER (PARTITION BY four), ten, 
four FROM
   (SELECT * FROM tenk1 WHERE unique2 < 10 ORDER BY four, ten)s
   ORDER BY four, ten;
                                                   QUERY PLAN
   
----------------------------------------------------------------------------------------------------------
    Gather Motion 3:1  (slice1; segments: 3)  (cost=0.00..6.01 rows=11 width=12)
      Merge Key: four, ten
      ->  Sort  (cost=0.00..6.00 rows=4 width=12)
            Sort Key: four, ten
            ->  WindowAgg  (cost=0.00..6.00 rows=4 width=12)
                  Partition By: four
                  ->  Sort  (cost=0.00..6.00 rows=4 width=8)
                        Sort Key: four
                        ->  Redistribute Motion 3:3  (slice2; segments: 3)  
(cost=0.00..6.00 rows=4 width=8)
                              Hash Key: four
                              ->  Index Scan using tenk1_unique2 on tenk1  
(cost=0.00..6.00 rows=4 width=8)
                                    Index Cond: (unique2 < 10)
    Optimizer: GPORCA
   (13 rows)
   ```
   
   This plan is wrong. In `WindowAgg` it should require the order of `four + 
ten`, but it only required the order of `four`.
   
   I guess this problem caused by subquery inline?
   
   ### What you think should happen instead
   
   _No response_
   
   ### How to reproduce
   
   upper
   
   ### Operating System
   
   all
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [x] Yes, I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/cloudberry/blob/main/CODE_OF_CONDUCT.md).
   


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