comphead opened a new issue, #22049:
URL: https://github.com/apache/datafusion/issues/22049

   ### Describe the bug
   
   Window function NTILE returns incorrect result
   
   ### To Reproduce
   
   ```
   DataFusion CLI v53.1.0
   > create or replace table test_table as select * from values (1, 0, 25),     
                                                                                
                                                                                
                       
       (1, 0, 10),                                                              
                                                                                
                                              
       (1, 1, 16),                                                              
                                                                                
                                              
       (1, 1, 1),                                                               
                                                                                
                                              
       (1, 2, 7),    
       (1, 2, 22),
       (1, 3, 13),                                                              
                                                                                
                                              
       (1, 3, 28),
       (1, 4, 19),                                                              
                                                                                
                                              
       (1, 4, 4),                                                               
                                                                                
                                              
       (2, 0, 5),                                                               
                                                                                
                                              
       (2, 0, 20),                                                              
                                                                                
                                              
       (2, 1, 26),                                                              
                                                                                
                                              
       (2, 1, 11),   
       (2, 2, 2),                                                               
                                                                                
                                              
       (2, 2, 17),   
       (2, 3, 8),                                                               
                                                                                
                                              
       (2, 3, 23),   
       (2, 4, 14),                                                              
                                                                                
                                              
       (2, 4, 29),
       (0, 0, 0),                                                               
                                                                                
                                              
       (0, 0, 15),   
       (0, 1, 21),
       (0, 1, 6),
       (0, 2, 12),                                                              
                                                                                
                                              
       (0, 2, 27),
       (0, 3, 3),                                                               
                                                                                
                                              
       (0, 3, 18),   
       (0, 4, 24),
       (0, 4, 9) t(a, b, c);
   0 row(s) fetched. 
   Elapsed 0.197 seconds.
   
   
   > select a, b, NTILE(4) OVER (PARTITION BY a ORDER BY b) as ntile_4 from 
test_table;
   +---+---+---------+
   | a | b | ntile_4 |
   +---+---+---------+
   | 0 | 0 | 1       |
   | 0 | 0 | 1       |
   | 0 | 1 | 1       |
   | 0 | 1 | 2       |
   | 0 | 2 | 2       |
   | 0 | 2 | 3       |      <------ wrong, should be 0, 2, 2
   | 0 | 3 | 3       |
   | 0 | 3 | 3       |
   | 0 | 4 | 4       |
   | 0 | 4 | 4       |
   | 1 | 0 | 1       |
   | 1 | 0 | 1       |
   | 1 | 1 | 1       |
   | 1 | 1 | 2       |
   | 1 | 2 | 2       |
   | 1 | 2 | 3       |
   | 1 | 3 | 3       |
   | 1 | 3 | 3       |
   | 1 | 4 | 4       |
   | 1 | 4 | 4       |
   | 2 | 0 | 1       |
   | 2 | 0 | 1       |
   | 2 | 1 | 1       |
   | 2 | 1 | 2       |
   | 2 | 2 | 2       |
   | 2 | 2 | 3       |
   | 2 | 3 | 3       |
   | 2 | 3 | 3       |
   | 2 | 4 | 4       |
   | 2 | 4 | 4       |
   +---+---+---------+
   30 row(s) fetched. 
   Elapsed 0.049 seconds.
   ```
   
   ### Expected behavior
   
   _No response_
   
   ### Additional context
   
   _No response_


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