geoffreyclaude opened a new pull request, #24997:
URL: https://github.com/apache/datafusion/pull/24997

   ## Which issue does this PR close?
   
   <!-- No issue filed -->
   
   ## Rationale for this change
   
   `Count` previously did not implement `order_sensitivity()`, defaulting to 
`AggregateOrderSensitivity::HardRequirement`. When `ORDER BY` was present in 
`COUNT`:
   1. Ordering keys were appended to accumulator inputs, causing 
single-argument grouped counts to panic in `CountGroupsAccumulator` 
(`assert_eq!(values.len(), 1)`).
   2. For counts evaluated via `CountAccumulator`, nullable ordering keys were 
evaluated as counted arguments by `null_count_for_multiple_cols`, incorrectly 
dropping rows where the ordering column was null.
   3. Redundant `SortExec` nodes were generated for an order-insensitive 
function.
   
   ## What changes are included in this PR?
   
   - Implemented `order_sensitivity` on `Count` returning 
`AggregateOrderSensitivity::Insensitive`.
   - Added test coverage in `aggregate.slt`.
   
   ## What is the testing strategy for this PR?
   
   - Added sqllogictests in `aggregate.slt` covering single-argument grouped 
count with `ORDER BY`, multi-argument count with nullable ordering keys, and 
non-grouped count with nullable ordering keys.
   
   ## Are there any user-facing changes?
   
   Fixes runtime panic and incorrect null-handling in `COUNT(... ORDER BY ...)`.


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