mustafasrepo opened a new issue, #7100:
URL: https://github.com/apache/arrow-datafusion/issues/7100

   ### Describe the bug
   
   Currently, `GroupOrderingPartial` expects its arguments `order_indices` and 
`ordering` to have same length. `ordering` is the output ordering of the 
aggregation, and `order_indices` is the indices of group by expressions inside 
`ordering`. 
   
   For most of the use cases, aggregate output ordering consists of only from 
group by expressions. For these cases, this check is valid. However, In 
Aggregate::Partial mode, when partition number is greater than 1, sometimes 
`ordering` contains fields from aggregator requirement expression. (This 
enables us to merge partitions correctly). Hence this expectation should be 
relaxed a bit.
   
   ### To Reproduce
   
   ```sql
   CREATE TABLE tab0(col0 INTEGER, col1 INTEGER, col2 INTEGER)
   statement ok
   INSERT INTO tab0 VALUES(83,0,38)
   
   statement ok
   INSERT INTO tab0 VALUES(26,0,79)
   
   statement ok
   INSERT INTO tab0 VALUES(43,81,24)
   
   # this case arise when partition number is greater than 1.
   statement ok
   set datafusion.execution.target_partitions = 8;
   
   query II
   SELECT l.col0, LAST_VALUE(r.col1 ORDER BY r.col0) as last_col1
   FROM tab0 as l
   JOIN tab0 as r
   ON l.col0 = r.col0
   GROUP BY l.col0, l.col1, l.col2
   ORDER BY l.col0;
   ```
   
   ### Expected behavior
   
   This query should run successfully.
   
   ### 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]

Reply via email to