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

   ### Is your feature request related to a problem or challenge?
   
   Today DataFusion supports three aggregate functions that can be "order 
aware": `ARRAY_AGG`, `FIRST_VALUE` and `LAST_VALUE`. This means that you can 
supply a `ORDER BY` clause to their argument, for example `FIRST_VALUE(x ORDER 
BY time)`. 
   
   Today, there be only one single order specified across ALL order aware 
aggregate functions
   
   For example
   ```SQL
   ❯ create table t(x int, y int) as values (1, 1), (1, 2), (1, 1), (1, 4), (2, 
20), (2, 10);;
   0 rows in set. Query took 0.003 seconds.
   
   ❯ select x, first_value(x ORDER BY y) from t GROUP BY x;
   +---+------------------+
   | x | FIRST_VALUE(t.x) |
   +---+------------------+
   | 2 | 2                |
   | 1 | 1                |
   +---+------------------+
   2 rows in set. Query took 0.004 seconds.
   
   ❯ select x, first_value(x ORDER BY y), first_value(x ORDER BY y DESC) from t 
GROUP BY x;
   +---+------------------+-----------------+
   | x | FIRST_VALUE(t.x) | LAST_VALUE(t.x) |
   +---+------------------+-----------------+
   | 1 | 1                | 1               |
   | 2 | 2                | 2               |
   +---+------------------+-----------------+
   2 rows in set. Query took 0.004 seconds.
   
   ❯ select x, first_value(x ORDER BY y), first_value(x ORDER BY y DESC NULLS 
LAST) from t GROUP BY x;
   This feature is not implemented: Conflicting ordering requirements in 
aggregate functions is not supported
   ```
   
   ### Describe the solution you'd like
   
   There are a few designs proposed here: 
https://github.com/apache/arrow-datafusion/pull/8558#issuecomment-1862649886
   
   We are working on a more detailed proposal 
   
   ### Describe alternatives you've considered
   
   _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]

Reply via email to